I'll get straight to the point.
I have the following procedure:
and this procedure:Code:public static String readLine (String prompt) { System.out.print( prompt ); try { InputStreamReader isr = new InputStreamReader (System.in); BufferedReader br = new BufferedReader(isr); String s = br.readLine (); System.out.println (""); return s; } catch (IOException e) { System.out.println("IO Exception "); e.printStackTrace(); System.exit (-1); } return "EXCEPTION"; } // end readLine
Code:public static void login() { String user = readLine("user:") ; String pass = readLine("pass:") ; System.out.println("user is " + user + " pass is " + pass) ; } // end login
both procedures are in the same .java file.
My question is, when im running this in a dos prompt window, If i want input from a file, I type
java [classname] < [input file]
right?
but when I have a simple text file with the following data:
scott
tiger
.. and I direct this file into my program with the above line of code, I get the following output:
"user is scott pass is null "
can someone please tell me why the second line in the text file is not being read in?
thanks in advance.



LinkBack URL
About LinkBacks



