Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.Scanner;
- public class testRead {
- public static void main(String[] args) throws Exception {
- try {
- File f = new File("file.txt");
- // if the file passed exists and is a file
- if(f.isFile()){
- Scanner s = new Scanner(f);
- while(s.hasNextLine())
- // outputs lines until eof
- System.out.println(s.nextLine());
- s.close();
- }
- }
- catch (Exception e) {
- System.exit(0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement