62,614
社区成员
发帖
与我相关
我的任务
分享
package http.hello;
import java.io.FileInputStream;
import java.io.IOException;
public class Demo6 {
public static void main(String[] args){
FileInputStream fileInput = null;
try{
fileInput = new FileInputStream("D:\\a.txt");
int c = 1;
//返回的是一个8位的数字,之所以返回类型是int而不是char,因为可能返回-1,文件结束标示EOF
while((c = fileInput.read()) != -1){
System.out.printf("%c",c);
}
}catch(Exception e){
}finally{
try {
fileInput.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}