Results 1 to 4 of 4

Thread: how do i catch Exception

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2002
    Location
    liverpool
    Posts
    9

    how do i catch Exception

    if i ask for a string through bufferReader i.e
    a telephone number 5554444
    how can i stop a letter being entered instead of a number

    thanks

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Not directly. You could read character per character and check each one. Or you could use a read-integer function (don't know if there is one), but it wouldn't hinder the user from entering a letter, it would only make the function throw an exception.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2002
    Location
    liverpool
    Posts
    9
    thanks i will check that way out

  4. #4
    Addicted Member Mrs Kensington's Avatar
    Join Date
    Sep 2001
    Location
    Dorset, UK
    Posts
    144
    or u can put the string u get into Integer.parseInt(String s)

    if this can't make it into an integer it throws an exception
    Ford? Theres an infinite number of monkeys outside that want to talk to you about a script of hamlet they've produced!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width