Hi, The problem is that the ".toString()" method won't work as you expected. The proper way to build a string with your acquired input is:
String fromCmdLine = new String(buffer). That makes sure your typed in ints will be coming in correctly. Best, Jos On Thu, Aug 27, 2009 at 5:21 AM, CJ<meiy...@163.com> wrote: > > I'm a college student. So this problem may be a little silly. Thanks > to help me. > Why it always throw the NumberFormatException? > --------------------------------------------------------------------------------------------------------------------- > ArrayList<Integer> inputNum = new ArrayList<Integer>(); > > try { > System.out.println(" Please input an integer:"); > while (true) { > byte buffer[] = new byte[128]; > System.in.read(buffer); > if ("end".equals(buffer.toString().trim())) { > break; > } > else { > inputNum.add(Integer.parseInt(buffer.toString().trim())); > } > } > } > catch (IOException e) { > System.out.println(e.toString()); > } > catch (NumberFormatException e) { > System.out.println("Please input an integer."); > } > -------------------------------------------------------------------------------------------------------------------- > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-java@googlegroups.com To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en -~----------~----~----~----~------~----~------~--~---