字符编码 转换流

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 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 }
ISR/OSW

 

posted @ 2020-09-27 10:07  享受折腾  阅读(130)  评论(0)    收藏  举报