public class ReadChineseFile {
public static void main(String[] args) throws IOException {
FileInputStream fis = new FileInputStream("笔记.txt"); //("笔记.txt") 为文本笔记
int b;
while ((b = fis.read()) != -1) {
byte b1 = (byte) b;
if (b1 < 0) {
byte b2 = (byte) fis.read();
byte[] arr = {b1, b2};
System.out.print(new String(arr)); //为什么要用new string()
} else {
System.out.print((char)b1);
}
}
fis.close();
}
}
|
|