|
|
вернуться в форумWhen i using BufferedReader of java with readLine function. It will read for 'N' lines that 'N' is specific. And when input is not specific of line, how should i deal with the input? How java knows the input string is ended? Sorry for bad english, bidakung my idea: BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); .......... try{ while(true){ .....in.readLine()....... } } catch(Exception e){} ........... the end of read by Exception. Edited by author 23.04.2011 17:40 you can not catch exceptions - this is a bug You can use StringTokenizer by reading the line as string and then dividing it into tokens. Scanner inputReader = new Scanner(System.in);
while(inputReader.hasNext()) { long n = inputReader.nextLong();
}
Edited by author 29.10.2011 02:14 Edited by author 29.10.2011 02:19 |
|
|