字符串编码、乱码相关问题

问题1.String的ReplaceAll("\\\\", File.separator);会抛出异常。

  解决方法:path = path.replaceAll("\\\\", Matcher.quoteReplacement(File.separator));

 

问题2.URL传中文乱码问题,可以通过各种不同编码的尝试,总有一个是对的。另外,在java中还可以用URLEncoder.encode(str, encoding)对字符串进行指定编码,传给服务器端。

 

 

你可能感兴趣的:(字符串)