I'm attempting to use the ObjectOutput/InputStream to write data to a file; I'm fairly certain I've got the out portion but coming back in isnt working as it should, thoughts?

    public static void writePersistant(ArrayList<PersistantObject> persistantRecords) {
        try {
            ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("dataout/population-record.ser"));

            for (PersistantObject i : persistantRecords) {
                oos.writeObject(i);
            }
            oos.close();
        } catch (FileNotFoundException ex) {
            System.out.println(ex.getMessage());
            System.out.println(ex.getStackTrace());
        } catch (IOException ex) {
            System.out.println(ex.getMessage());
            System.out.println(ex.getStackTrace());
        }

    }

    public static void readerPersistant() {
        try {
            ObjectInputStream ois = new ObjectInputStream(new FileInputStream("dataout/population-record.ser"));

            Object inputObj = null;

            while ((inputObj = ois.readObject()) != null) {
                if (inputObj instanceof PersistantObject) {
                    System.out.println(inputObj);
                }
            }
        } catch (FileNotFoundException ex) {
            System.out.println(ex.getMessage());
            System.out.println(ex.getStackTrace());
        } catch (IOException | ClassNotFoundException ex) {
            System.out.println(ex.getMessage());
            System.out.println(ex.getStackTrace());
        }
    }
}

in isnt working as it should

Please explain what the program does and what "is not working as it should" means.
Post the output from the program.

How do you test the code? Do you have a small complete program that compiles, excutes and shows the problem?

Bah nm it was a matter of implementing the Serializable in the proper classes. =(

Please mark this "solved" so people don't waste time trying to help with it, and also so the problem & solution will be part of our knowledge base
J

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.