From: Charles R. <cr...@ri...> - 2003-05-30 04:53:17
|
We have just added support for reading input from System.in in the drjava-20030529-2239 development release. The program you mention below will now direct the user to enter input into the Console tab, which becomes editable when input is requested from System.in. Please give it a try and let us know what you think! You can download the release from the "more download options" link on http://drjava.org. Thanks, Charlie Reis On Mon, 30 Sep 2002, 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 > |