Monday 7 October 2013

Read File Contents Using Scanner



import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class UsingScanner {

public static void main(String[] args) throws FileNotFoundException {
Scanner s=new Scanner(new File("d:/ram.txt"));
while (s.hasNextLine()) {
                           String line = s.nextLine();
                           System.out.println(line);
                }
s.close();
}

}

No comments:

Post a Comment