I have such code to read a text file using BufferedReader:
BufferedReader reader=null;
try {
reader = new BufferedReader(new FileRea
Look at the API for ready.
What you're doing is wrong. ready() only tells you if the stream is readable and valid. Read the comment under return on that link as well.
What you want to do is:
String thisLine;
//Loop across the arguments
for (int i=0; i < args.length; i++) {
//Open the file for reading
try {
BufferedReader br = new BufferedReader(new FileReader(args[i]));
while ((thisLine = br.readLine()) != null) { // while loop begins here
System.out.println(thisLine);
} // end while
} // end try
catch (IOException e) {
System.err.println("Error: " + e);
}
} // end for