Results 1 to 6 of 6
  1. #1
    AlphaRaveNZ is offline Member
    Join Date
    May 2012
    Posts
    3
    Rep Power
    0

    Default loading file data into arraylist...

    Hi, im trying to load data from a file, created by my project, back into my project. My load function code is:

    myFile.showOpenDialog(this);
    path = myFile.getSelectedFile().getPath();

    try
    {
    ObjectInputStream in = new ObjectInputStream(new FileInputStream(path));
    txtMessage.append("Error Checking 1...\n");//Error checking...
    myInput.cameraList = (ArrayList<String>)in.readObject();
    txtMessage.append("Error Checking 2...\n");//Error checking...
    txtMessage.append("Loading\n");
    txtMessage.append("Loaded camera data from file... " + myInput.cameraList+"\n");
    }

    catch (Exception err2)
    {
    txtMessage.append("Error loading data... "+err2.getMessage()+"\n");
    }

    I am given this message: "Error loading data... null"

    I have error checking as you can see, the line of code that its getting stuck on is the line just after "Error checking... 1". Im not sure whats wrong though, im not getting any complie errors...

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: loading file data into arraylist...

    The printStackTrace method is invaluable in determining the true exception and the underlying problem. I recommend using this (or a form of it) to get the full stack trace of the exception.

  3. #3
    AlphaRaveNZ is offline Member
    Join Date
    May 2012
    Posts
    3
    Rep Power
    0

    Default Re: loading file data into arraylist...

    Quote Originally Posted by doWhile View Post
    The printStackTrace method is invaluable in determining the true exception and the underlying problem. I recommend using this (or a form of it) to get the full stack trace of the exception.
    Thanks for answer, not to sure what your talking about through sorry, im fairly new to java and programming as a whole.

  4. #4
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: loading file data into arraylist...

    catch (Exception err2)
    {
    err2.printStackTrace();
    }
    Post the entirety of the result from the above in the catch statement

  5. #5
    AlphaRaveNZ is offline Member
    Join Date
    May 2012
    Posts
    3
    Rep Power
    0

    Default Re: loading file data into arraylist...

    I put it into my code, it came up underlined in yellow and said "Throwable.printStackTrace(); should be removed". i tried running it anyway but it didnt display an error message.

    p.s. im in doing this in netbeans, if it makes any difference...

  6. #6
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: loading file data into arraylist...

    Quote Originally Posted by AlphaRaveNZ View Post
    I put it into my code, it came up underlined in yellow and said "Throwable.printStackTrace(); should be removed".
    I have no idea what that means, and you didn't post updated code of what you did...so one can only guess. I suggest you read upon on Exceptions handling:
    Lesson: Exceptions (The Java™ Tutorials > Essential Classes)

Similar Threads

  1. loading data from a text file
    By newbie123 in forum JDBC
    Replies: 1
    Last Post: 06-21-2011, 06:09 PM
  2. Replies: 4
    Last Post: 01-11-2011, 03:31 PM
  3. Load data from file to ArrayList
    By humbug in forum New To Java
    Replies: 3
    Last Post: 01-05-2011, 11:53 AM
  4. loading data in memory
    By robby14 in forum Advanced Java
    Replies: 10
    Last Post: 04-18-2010, 02:29 PM
  5. Storing data from text file in ArrayList
    By tjhodge in forum New To Java
    Replies: 1
    Last Post: 02-12-2009, 01:22 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
  •