Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

How to Read a Line of Input Using Version 1.4.2

Thread view: 
kvnsmnsn@hotmail.com - 28 Mar 2007 19:23 GMT
I've been working with Java version 1.5 for some time, but now I have
a new job where the Java version they use is 1.4.2, which means it
doesn't allow class <Scanner>.  Does anybody out there know how to
read a line of input from the user that will work with version 1.4.2?
I'm guessing I have to use <System.in> somewhere, but I don't know
precisely how to do it.  Any information would be appreciated.

                               ---Kevin Simonson

"You'll never get to heaven, or even to LA,
if you don't believe there's a way."
from _Why Not_
Kimba - 28 Mar 2007 19:50 GMT
Try to create a convenience method like this:

   private String input(String prompt) {
       //--- Write out the prompt
       System.out.print(prompt);
       //--- Create a Reader
       BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
       //--- Read the user's input
       try {
           return br.readLine();
       }
       //--- We had an exception: Return NULL
       catch(IOException e) {
           return null;
       }
   }
kvnsmnsn@hotmail.com - 28 Mar 2007 20:32 GMT
> Try to create a convenience method like this:
>
[quoted text clipped - 13 lines]
>         }
>     }

Thanks!  This worked just fine.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.