read the program input from text file

How to set and read the program input from text file instead of keyboard

Other day i was trying to take part in some online programming tests and generally we have to give our program which is compliant to certain guidelines.

One of them is that input has to be given from keyboard.

For testing locally i suggest that you can make one text file to give input all in one go

Some thing like

System.setIn(new FileInputStream(
"D:\\Development\\eclipse_workspace\\RandomInterview\\src\\1.txt"));

This will set the System.in to the text file specified and you can see the output in console.

Happy Programming

Useful link

http://stackoverflow.com/questions/188547/eclipse-reading-stdin-system-in-from-a-file

No comments:

Post a Comment

Please share your views and comments below.

Thank You.