文件复制乱码问题 FileInputStream fis = new FileInputStream("b.txt");
InputStreamReader isr = new InputStreamReader(fis);
FileOutputStream fos = new FileOutputStream("copy_b.txt");
OutputStreamWriter osw = new OutputStreamWriter(fos);
int i = -1;
while((i = isr.read()) != -1){
System.out.print((char)isr.read());
osw.write(i);
}
isr.close();
osw.close();
复制后的文件乱码,请各位高手帮我看看是哪里的问题,谢谢!
乱码复制文件
分享到:
------解决方案--------------------
Reader r = new BufferedReader(new InputStreamReader(in, System.getProperty("file.encoding")));
Writer w = new BufferedWriter(new OutputStreamWriter(out, System.getProperty("file.encoding")));