StremCorrupted Exception reading on an object

hi guys i m getting StreamCorruptedException just don't know why. its a simple program. below is my main class.package Basics1;

import java.util.*;

import java.io.*;

publicclass UseStaticIpData{

public UseStaticIpData(){

}

publicstaticvoid main(String[] args)throws IOException{

StaticIpData sipd =new StaticIpData();

FileIpData fipd =new FileIpData();

ArrayList al =new ArrayList();

for(int i=0;i<3;i++){

sipd.setIp1(i);

sipd.setIp2(i);

sipd.setIp3(i);

sipd.setIp4(i);

fipd.setStaticIpData(sipd);

}al = fipd.getStaticIpDataAsList();

Iterator ir = al.iterator();

while(ir.hasNext()){

System.out.println(((StaticIpData)ir.next()).getIpAsString());

}

}

}

and the two helper classespackage Basics1;

import java.io.*;

import java.util.*;

publicclass FileIpData{

StaticIpData sipd =new StaticIpData();

public FileIpData(){

}

publicvoid setStaticIpData(StaticIpData si){

try{

ObjectOutputStream oos =new ObjectOutputStream(new FileOutputStream("data.txt",true));

oos.writeObject(si);

oos.flush();

oos.close();

}catch(FileNotFoundException fnfe){

System.out.println("called out fnfe");

}catch(IOException ioe){

System.out.println("called out ioe");

}finally{

}

}

public ArrayList getStaticIpDataAsList()throws IOException{

ArrayList al =new ArrayList();

ObjectInputStream ois;// = new ObjectInputStream(new FileInputStream("data.txt"));

try{

ois =new ObjectInputStream(new FileInputStream("data.txt"));

while(true){

al.add((StaticIpData)ois.readObject());

}

//ois.close();

}catch(EOFException eofe){

System.out.println("called in eof");

}catch(FileNotFoundException fnfe){

System.out.println("called in fnfe");

}catch(ClassNotFoundException cnfe){

System.out.println("called in cnfe");

}finally{

}

return al;

}

}

and this onepackage Basics1;

import java.io.*;

import java.util.*;

publicclass FileIpData{

StaticIpData sipd =new StaticIpData();

public FileIpData(){

}

publicvoid setStaticIpData(StaticIpData si){

try{

ObjectOutputStream oos =new ObjectOutputStream(new FileOutputStream("data.txt",true));

oos.writeObject(si);

oos.flush();

oos.close();

}catch(FileNotFoundException fnfe){

System.out.println("called out fnfe");

}catch(IOException ioe){

System.out.println("called out ioe");

}finally{

}

}

public ArrayList getStaticIpDataAsList()throws IOException{

ArrayList al =new ArrayList();

ObjectInputStream ois;// = new ObjectInputStream(new FileInputStream("data.txt"));

try{

ois =new ObjectInputStream(new FileInputStream("data.txt"));

while(true){

al.add((StaticIpData)ois.readObject());

}

//ois.close();

}catch(EOFException eofe){

System.out.println("called in eof");

}catch(FileNotFoundException fnfe){

System.out.println("called in fnfe");

}catch(ClassNotFoundException cnfe){

System.out.println("called in cnfe");

}finally{

}

return al;

}

}

please help i've been stuck for 2 days now and unable to find a solution. also api doesn't explain much why streamsgetcorrupted

[8160 byte] By [rajitoora] at [2007-11-27 8:20:02]
# 1
I think you listed the code of FileIpData.java twice,...could you put the StaticIpData.java code?cya
pbulgarellia at 2007-7-12 20:08:18 > top of Java-index,Core,Core APIs...
# 2

> ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("data.txt",true));

The problem is here. You can't append to an ObjectOutputStream. This question was answered several days ago somewhere else.

ejpa at 2007-7-12 20:08:18 > top of Java-index,Core,Core APIs...