下述代码的两种读取文件的方法的输出结果不一样,注释掉的才能正确读取全部内容,而另一种只能读取部分没人且不按顺序。求教各位 public void read(File file) throws IOException { FileInputStream fis = new FileInputStream(file); int data; System.out.print("文件中的内容是 "); while(fis.read()!=-1) { System.out.print((char)(fis.read())); }// while((data = fis.read()) != -1) {// System.out.print((char)data);// } fis.close(); }
添加回答
举报
0/150
提交
取消