|
|
back to boardHow java deal with these input? 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 Re: How java deal with these input? Posted by tagetes 23 Apr 2011 15:29 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 Re: How java deal with these input? you can not catch exceptions - this is a bug Re: How java deal with these input? Posted by pausuk 24 Sep 2011 18:15 You can use StringTokenizer by reading the line as string and then dividing it into tokens. Re: How java deal with these input? Posted by Fatemeh 29 Oct 2011 02:08 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 |
|
|