Results 1 to 3 of 3
  1. #1
    osval is offline Member
    Join Date
    Jul 2007
    Posts
    26
    Rep Power
    0

    Default java.lang.NumberFormatException: For input stream:jav

    I'm working on a Mail Client using SMTP protocol.
    The code compiles fine but when I run the code with valid inputs and click the send button an exception appears

    Java Code:
     
    java.lang.NumberFormatException: For input stream:"jav".
    any ideas?

  2. #2
    bbq
    bbq is offline Senior Member
    Join Date
    Jun 2007
    Posts
    132
    Rep Power
    0

    Default

    Can you paste your code?

  3. #3
    osval is offline Member
    Join Date
    Jul 2007
    Posts
    26
    Rep Power
    0

    Default

    I solved my problem!
    in the line
    Java Code:
    int code = Integer.parseInt(reply.substring(0,3));
    That has to be what's throwing the NumberFormat exception. I had to put a try block in there and return -1 if an exception is indeed thrown.

    output the substring before you try to parse it so you can see exactly what it's trying to parse.
    Last edited by osval; 08-07-2007 at 04:13 PM.

Similar Threads

  1. Replies: 2
    Last Post: 09-18-2008, 07:30 AM
  2. Error: NumberFormatException
    By coco in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 07:41 AM
  3. how to take input and verify input in Java programs
    By bilal_ali_java in forum Advanced Java
    Replies: 0
    Last Post: 07-21-2007, 08:46 AM
  4. java.lang.NumberFormatException: null
    By Eric in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 07-05-2007, 05:31 AM
  5. stream redirection
    By Ed in forum New To Java
    Replies: 1
    Last Post: 07-02-2007, 04:34 PM

Posting Permissions

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