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 / First Aid / November 2005

Tip: Looking for answers? Try searching our database.

Exception 2 - string...HELP

Thread view: 
toy - 07 Nov 2005 20:30 GMT
Miller_Rabin.java:24: unreported exception java.io.IOException; must be
> caught or declared to be thrown
>    String ns  = stdin.readLine();
VisionSet - 07 Nov 2005 20:50 GMT
> Miller_Rabin.java:24: unreported exception java.io.IOException; must be
> > caught or declared to be thrown
> >    String ns  = stdin.readLine();

It may throw a 'checked' exception so you must provide a way to deal with
that possibility.

String ns = null;
try {
   ns = stdin.readLine();
}
catch(java.io.IOException ex) {
   ex.printStackTrace();
}

note ns is declared outside of the try/catch block so that the reference
remains in scope so you can use it later.

--
Mike W
toy - 07 Nov 2005 21:23 GMT
thanks so much :-D
Oliver Wong - 07 Nov 2005 21:51 GMT
> thanks so much :-D

   You know what they say about teaching a man to fish versus giving him a
fish every day?

   If you're going to have to stop coding and post a question on the
newsgroup every time you encounter a method which throws an Exception,
you're going to be a very slow Java programmer.

   I strongly recommend that you read Sun's tutorial on exception handling.
That way, when you encounter a problem like this, you can solve it yourself,
thus saving yourself time which you can spend helping newbies on the
newsgroup (or spend playing video games or just sleeping or whatever you
want to do with your time).

   Here's the link again:

http://java.sun.com/docs/books/tutorial/essential/exceptions/

   - Oliver


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



©2008 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.