Results 1 to 2 of 2
  1. #1
    Buttons is offline Member
    Join Date
    Mar 2013
    Posts
    1
    Rep Power
    0

    Default Help! Keep getting an Error --> NumberFormatException: For Input String

    This is my code, any help would be much appreciated thanks :)
    The error seems to be occurring in this line:

    Events(Integer.parseInt(readlines[0]),readlines[1],readlines[2],Integer.parseInt(readlines[3]),readlines[4],
    Integer.parseInt(readlines[5]),Integer.parseInt(readlines[6]),Integer.parseInt(readlines[7]),Integer.parseInt(readlines[8]));


    >>>>>>>>>>>>CODE<<<<<<<<<<<<<<<


    import java.util.ArrayList;
    import java.io.*;
    import java.util.*;

    public class TestProject
    {
    public static ArrayList<Events> events = new ArrayList<Events>();
    public static ArrayList<Organisers> organisers = new ArrayList<Organisers>();
    public static void main (String [] args) throws IOException

    {
    Organisers aOrganiser;
    Events aEvent;
    String OrgName = "";
    FileReader aFileReader = new FileReader("Organisers.txt");
    Scanner in = new Scanner(aFileReader);
    String aLineFromFile = null;
    BufferedReader Org = new BufferedReader(new FileReader(new File("Organisers.txt")));
    String line = null;
    BufferedReader Ev = new BufferedReader(new FileReader(new File("Events.txt")));


    while ((aLineFromFile = Ev.readLine()) != null)
    {
    String[] readlines = aLineFromFile.split(",");

    aEvent = new Events(Integer.parseInt(readlines[0]),readlines[1],readlines[2],Integer.parseInt(readlines[3]),readlines[4],
    Integer.parseInt(readlines[5]),Integer.parseInt(readlines[6]),Integer.parseInt(readlines[7]),Integer.parseInt(readlines[8]));
    events.add(aEvent);

    String [] anEvent = new String[events.size()];

    for (int k = 0; k < events.size(); k++)
    {
    anEvent[k] = events.get(k).getEvTitle();
    }

    Object selectedValue2 = JOptionPane.showInputDialog(null,"Click arrow for list of events",
    "Pick event", 1, null, anEvent, anEvent[0]);

    int i = organisers.size()-1;
    JOptionPane.showMessageDialog(null,((organisers.ge t(i)).getOrgName()));
    }


    while ((line = Org.readLine()) != null)
    {
    String[] readlines = line.split(",");

    aOrganiser = new Organisers(Integer.parseInt(readlines[0]),readlines[1],readlines[2],readlines[3],readlines[4]);
    organisers.add(aOrganiser);
    }

    for(int j = 0 ; j < organisers.size(); j++)
    System.out.println(organisers.get(j).getOrgName() + "\n");

    }
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Help! Keep getting an Error --> NumberFormatException: For Input String

    You need to expand your code, make it less compact making it easier to isolate your error. For instance parse each number into a variable, and do each parse on its own line.

Similar Threads

  1. java.lang.NumberFormatException: For input string: ""
    By deshmukh.niraj04 in forum New To Java
    Replies: 16
    Last Post: 08-22-2011, 02:02 PM
  2. Replies: 14
    Last Post: 04-08-2011, 07:01 PM
  3. java.lang.NumberFormatException: For input string: ""
    By chathura992 in forum New To Java
    Replies: 3
    Last Post: 01-08-2011, 02:10 AM
  4. jsp insert into database error(java.lang.NumberFormatException: For input string: "")
    By cypher_girl in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 12-22-2009, 04:14 AM
  5. Replies: 2
    Last Post: 08-07-2007, 04:50 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
  •