Results 1 to 2 of 2
  1. #1
    sudec is offline Member
    Join Date
    Jul 2009
    Posts
    2
    Rep Power
    0

    Unhappy Saveobject to file

    Hi,

    I would really need some help on this.
    I'm writing a program where I save all my data to an arrayList. Then I need is to save this List to a file and open (or load) this file when the program starts.

    I have two functions. One for saving the list and one for opening as follow:

    public static void load() {
    try {
    FileInputStream fis = new FileInputStream("file.in");
    ObjectInputStream ois = new ObjectInputStream(fis);
    Main.pole = (List<zaznam>)ois.readObject();
    ois.close();
    } catch (IOException iOException) {
    } catch (ClassNotFoundException classNotFoundException) {
    }
    System.out.print(Main.pole);

    }

    public static void save(){
    try{
    FileOutputStream o = new FileOutputStream("file.in");
    ObjectOutputStream out= new ObjectOutputStream(o);
    out.writeObject(pole);
    out.close();
    }
    catch (IOException e1){
    }
    System.out.println(pole);
    }


    pole - the name of the list


    Please help on this. Thanks

  2. #2
    sudec is offline Member
    Join Date
    Jul 2009
    Posts
    2
    Rep Power
    0

    Default

    Ok. I solved it. I was actually missing the implements Serializable so nevermind

Similar Threads

  1. Replies: 2
    Last Post: 04-07-2009, 06:25 AM
  2. Replies: 0
    Last Post: 02-11-2009, 09:53 AM
  3. Replies: 7
    Last Post: 11-19-2008, 02:09 PM
  4. To open an image file such as Jpeg file using JAva Program
    By itmani2020 in forum Advanced Java
    Replies: 10
    Last Post: 07-11-2008, 09:57 AM
  5. Replies: 7
    Last Post: 05-23-2008, 03:46 AM

Posting Permissions

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