![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
package lab01; import java.util.*; import java.math.*; import java.io.*; public class first { public static void main(String[] args) { String fileName = "E:/eclipse/mywork/in.txt"; try { File file = new File(fileName); Scanner workreader = new Scanner(file); while (workreader.hasNext()) { String nn = workreader.nextLine(); System.out.println(nn); } // FileReader fr = new FileReader(fileName); // BufferedReader br = new BufferedReader(fr); // String line = br.readLine(); // while (line != null) { // System.out.println(line); // line = br.readLine(); // } } catch (Exception io) { io.printStackTrace(); } } }