trouble with objectInputStream
the problem is that i cannot added anythig to the data storage. i can add one item and then when i try and add another item, i get an end of file error.
i would really appreciate some help cause ive been trying to fix this problem for a while. -- thanks
/* initialize file for customer storage
* create a new customer vector
* if file not found tell user (recover gracefully)
* read customer instance from file and add to vector
* reads objects to selected file
*/
publicstaticvoid initializeFile()
{
// create Vector instance to hold customer reference variables
customers =new Vector();
if(customerFile.exists() && customerFile.length() != 0)
{
try
{
ObjectInputStream in =new ObjectInputStream(new FileInputStream (customerFile));
// read all customer objects in if customer file exists and length
try
{
while(customerFile.exists())
{
customers.addElement(in.readObject());
}
}
catch(Exception ex)
{
//System.err.println("end of file: error 1 " + ex); //end of file
JOptionPane.showMessageDialog(null,"End of File: " + ex,"Alert!",JOptionPane.ERROR_MESSAGE);
}
}
catch (IOException e)
{
//JOptionPane.showMessageDialog(null,"Input/Ouput Error " + e, "Alert!",JOptionPane.ERROR_MESSAGE);
System.err.println ("Input/Output Error: " + e);
}
}
}

