字符编码 转换流

 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 }
 
                    
                     
                    
                 
                    
                
 
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号