Reading in from - Java

The Solution to Reading in from - Java is

You can use to read from the standard input. It works just like entering it from a keyboard. The OS handles going from file to standard input.

class MyProg {

    public static void main(String[] args) {
        Scanner sc = new Scanner(;
        System.out.println("Printing the file passed in:");
        while(sc.hasNextLine()) System.out.println(sc.nextLine());

~ Answered on 2011-03-30 15:01:58

Most Viewed Questions: