1 public class StreamDemo { 2 public static void main(String[] args) throws IOException { 3 InputStreamReader isr = new InputStreamReader(new FileInputStream("d:\\2.xml"),"GBK"); 4 OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("d:\\1.xml"),"UTF-8"); 5 char[] chars = new char[2048]; 6 int len = 0; 7 while ((len = isr.read(chars)) != -1) { 8 osw.write(chars, 0, len); 9 } 10 osw.close(); 11 isr.close(); 12 } 13 }
原文:https://www.cnblogs.com/neoo9901/p/13737915.html