-
Serilization eror
OBJ= :cry: (Add) din.readObject();
while(OBJ!=null)
{
System.out.println(OBJ.s1);
System.out.println(OBJ.s1);
OBJ=(Add)din.readObject();
}
when i used the above code ihave got
EOFException how i get end of file
is there an other method
and i have "next"
button how i control the cursor mean
how i get the next or privious record in
the file
thank in advance
-
Re: Serilization eror
Instead of trying this:
Code:
if (obj != null)
{
}
Try doing this:
Usually the end of file exceptions are thrown whenever a -1 is returned, signifying that it's the end of a file.
-
Re: Serilization eror
It would help if you could provide more code. Plus why are you reading the object twice? You already have the object returned from readObject(). Here's some code which might help.
Code:
import java.io.*;
public class Y{
public static void main(String[] args){
ObjectInputStream oip = null;
try{
oip = new ObjectInputStream(new FileInputStream("C:" + File.separator + "ObjSerFile"));
SerObj serobj = (SerObj)oip.readObject();
System.out.println(serobj.getTemp());
System.out.println(serobj.getIndicator());
}catch(Exception io){
System.err.println(io);
}finally{
try{
oip.close();
}catch(IOException io){
System.err.println(io);
}
}