i have append an object to a existing file but i can not read it ,i can read the first object and this is my code What is the problem ??
try{
FileOutputStream fos = openFileOutput("f.txt",MODE_PRIVATE | MODE_APPEND );
ObjectOutputStream oos = new ObjectOutputStream(fos);
String a=new String ("Hello object1 ");
String b=new String("Hello object2 ");
String c=new String("Hello object3 ");
oos.writeObject(a);
oos.writeObject(b);
oos.writeObject(c);
oos.close();
// Reading it back..
FileInputStream fis = openFileInput("f.txt");
ObjectInputStream ois = new ObjectInputStream(fis);
//ois=new ObjectInputStream(fis);
// r=(String)ois.readObject();
String r;
while ((r= (String)ois.readObject()) != null) {
Log.i("while Read r",r);
Toast.makeText(getApplicationContext(),r, Toast.LENGTH_SHORT).show();
}
ois.close();
}catch (Exception e){
Log.i("Exception",e.getMessage());
}
我希望你们能够帮助我! 感谢。