问下大家为什么我输出 "郑泉" 这个字符串到文本里会出现乱码,其他的就不会呢
问下编码保存格式要求是ANSI。到底 "郑泉" 这是特殊字符,还是? 请教大家。附上以下代码:
InputStream is = new ByteArrayInputStream("郑泉".getBytes());
OutputStream os;
os = new FileOutputStream("d:\\qq.txt");
byte[] buffer = new byte[2048];
int length = 0;
while (-1 != (length = is.read(buffer, 0, buffer.length))) {
os.write(buffer, 0, length);
}
is.close();
os.close();
------解决方案--------------------
InputStream is = new ByteArrayInputStream(new String("郑泉".getBytes("GBK"),"ANSI"));
试试