From: Charles R. <cr...@ri...> - 2002-09-30 21:48:03
|
At the moment, DrJava does not support reading from System.in within the Interactions pane. There are both logistical and pedagogic reasons for this, but I'm not sure what our final decision will be yet-- it's still a topic of discussion. There's some related information on this report: http://sourceforge.net/tracker/index.php?func=detail&aid=604309&group_id=44253&atid=438935 I'll try to keep you updated on our decision, but it might be worth looking into avoiding System.in (given the strengths of the Interactions pane). Charlie Carl Pulley wrote: > Dear all, > I'm having problems using some code to simplify keyboard input for my > students (Dr.Java version 20020814-0343; JDK 1.3.1; OS Mac OSX 10.2.1 - > reported problems are also verified on a Solaris setup). > > The code I'm using is as follows: > > public class read { > > static public int getInt(String prompt) { > System.out.print(prompt); > BufferedReader In = new BufferedReader(new > InputStreamReader(System.in)); > while (true) { > try { > System.out.print("[GetInt]"); > String s = (In.readLine()).trim(); > int y = (new Integer(s)).intValue(); > return y; > } catch (Exception e) { > System.out.println("Incorrect input format, please enter again: "); > } > } > } > > } > > and the following is typed into the interactions pane: > > int x = read.getInt("enter: "); > > The result is that Dr.Java hangs with a spinning wrist watch. > > As far as I can tell, the problem seems to be that my code is assuming > that keyboard input will be derived from the System.in stream. I guess > that Dr. Java assumes that keyboard input derives from an alternative > stream? > > Any help with this one or alternative code for simplifying keyboard > input is greatly appreciated. > > Many thanks in advance, > > Carl. > > -- > Dr. Carl Pulley (Lecturer) > School of Computing and Mathematics, > University of Huddersfield, email: c.j...@hu... > Huddersfield WWW: http://scom.hud.ac.uk/scomcjp > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Drjava-users mailing list > Drj...@li... > https://lists.sourceforge.net/lists/listinfo/drjava-users |