aspose file tools
The moose likes Beginning Java and the fly likes throwsjava.io.IOException Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "throwsjava.io.IOException" Watch "throwsjava.io.IOException" New topic
Author

throwsjava.io.IOException

Chinedu Ezenwanne
Greenhorn

Joined: Oct 01, 2003
Posts: 3
trying to use the io format to write a code that allows a user punch in 8
nos b/w 0 & 9 like in a pin code
So far I've here is were I am

/* this is my first attempt at coding using throws java io
trying to see if i could mimic reload a recharge voucher on to a cellphone.
*/

class Pincode {
public static void main (String args [])
throws java.io.IOException
int codename
// Hope I'm making sense,if not could someone correct me & put me on course
thanks
Herb Schildt
Author
Ranch Hand

Joined: Oct 01, 2003
Posts: 239
Chinedu:
Here are a couple of points to help you get started.
You can read a string from the keyboard using the following sequence

To convert the string into an integer, you can use this code:

Notice that you have to catch and handle NumberFormatException, which is thrown if the string being converted into an integer does not contain a valid integer value.
One other point, although it is common in example programs to simply throw IOException out of main(), as you code does, you could also handle it inside main() by using a try/catch block similar to that required by Integer.parseInt().

If you are still having problems, let us know.


For my latest books on Java, including my Java Programming Cookbook, see HerbSchildt.com
 
I agree. Here's the link: http://jrebel.com/download
 
subject: throwsjava.io.IOException
 
Similar Threads
doubt in exception
I/o Error when getting outputstream
Javadoc: What to document if one exception is caught and another is throwed?
Socket connect timed out and connection refuse
insufficient privileges in oracle