FileReader processing of Java files can be output Chinese characters

Import java.io.FileNotFoundException;
 Import java.io.FileReader;
 Import java.io.IOException; 

public  class FileReaderDemo1 {
     public  static  void main (String [] args) throws IOException {
         // file name created stream object 
        the FileReader fr = new new the FileReader ( "a.txt" );
         // define a variable, save the data 
        int C;
         the while (! (C = fr.read ()) = -. 1) { // read each time a character 
            System.out.println (( char ) C); // output Chinese characters 
        } 

//        char [] = new new charBuff char [2]; 
 //         the while (! (len = fr.read (charBuff)) = -. 1) { // read each time two characters
 //             System.out.println (new new String (charBuff));
 // 
//         } 

        fr.close (); // close the resource
 
    } 
}

 

Guess you like

Origin www.cnblogs.com/theworld/p/11641937.html