Hello, I need to read in objects from a binary file and place those objects into an ArrayList. Not sure on how to go about adding the objects - this is what I have so far:
ArrayList<MailingLabel> arrayOfMailingLabels = new ArrayList<MailingLabel>();
try
{
ObjectInputStream in = new ObjectInputStream(new FileInputStream("labels.dat"));
while (in.readObject() != null)
{
arrayOfMailingLabels.add(in.readObject());
}
in.close();
} // end try
catch(IOException ioe)
{
ioe.printStackTrace();
}
Previous to this, I read in mailing labels from a txt file, placed the content into an ArrayList as an object, and read those objects into this binary file - fyi. Any help is greatly appreciated, thanks.