0
我想发送html文件内容来请求参数。 问题区域位于服务器端,获取一些额外的字符。通过android的服务器发送html内容
<!Document....> the other side ?<!Document...>
为什么这个“?”马克来了。 任何人都可以帮我弄清楚。 在此先感谢。
我想发送html文件内容来请求参数。 问题区域位于服务器端,获取一些额外的字符。通过android的服务器发送html内容
<!Document....> the other side ?<!Document...>
为什么这个“?”马克来了。 任何人都可以帮我弄清楚。 在此先感谢。
最后我得到了我的问题的解决
import java.io.*;
公共类UTF8ToAnsiUtils {
// FEFF because this is the Unicode char represented by the UTF-8 byte order mark (EF BB BF).
public static final String UTF8_BOM = "\uFEFF";
public static void main(String args[]) {
try {
if (args.length != 2) {
System.out
.println("Usage : java UTF8ToAnsiUtils utf8file ansifile");
System.exit(1);
}
boolean firstLine = true;
FileInputStream fis = new FileInputStream(args[0]);
BufferedReader r = new BufferedReader(new InputStreamReader(fis,
"UTF8"));
FileOutputStream fos = new FileOutputStream(args[1]);
Writer w = new BufferedWriter(new OutputStreamWriter(fos, "Cp1252"));
for (String s = ""; (s = r.readLine()) != null;) {
if (firstLine) {
s = UTF8ToAnsiUtils.removeUTF8BOM(s);
firstLine = false;
}
w.write(s + System.getProperty("line.separator"));
w.flush();
}
w.close();
r.close();
System.exit(0);
}
catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
private static String removeUTF8BOM(String s) {
if (s.startsWith(UTF8_BOM)) {
s = s.substring(1);
}
return s;
}
}
你会发现在这个环节上更详细.. http://www.rgagnon.com/javadetails/java-handle-utf8-file-with-bom.html