• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

throwsjava.io.IOException

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Author
Posts: 253
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic