import java.io.*;
public class sample {
public static void main(String[] args) {
try{
int rs;
File file=new File("C:\\","test.txt");
FileInputStream fis =new FileInputStream(file);
InputStreamReader isr=new InputStreamReader(fis);
while((rs=isr.read())!=-1)
/*顺序读取文件里的内容并赋值给整型变量b,直到文件结束为止(False)*/
System.out.print((char)rs);
isr.close();
}catch(IOException e){
e.printStackTrace();
}
}
}
运行结果
网友评论