package com.java_io.FileInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
//汉字读不出 因为字节读取 汉字由两个字节组成
public class TestFileInputStream {
public static void main(String[] args) {
int b = 0;
FileInputStream in = null;
try {
in = new FileInputStream(
"E:\\学习\\java\\eclipse_EN\\progrm\\java_io1\\src\\com\\java_io\\FileInputStream\\TestFileInputStream.java");
} catch (FileNotFoundException e) {
System.out.println("找不到指定文件");
System.exit(-1);
}
try {
long num = 0;
while ((b = in.read()) != -1) {
System.out.print((char) b);
num++;
}
in.close();
System.out.println();
System.out.println("共取了" + num + "个字节");
} catch (IOException e1) {
System.out.println("文件读取错误");
System.exit(-1);
}
}
}
读出来的字符