Hi friend,
The code below seems to compile fine but gives the java.io.NotActiveException at the //..............(*)
positions. Can Anyone help me to find the light ....Il be sincerely grateful,
Thanx in Advance,
Ranj
//**********************************
import java.io.*;
class Main {
Dummy object = new Dummy();
public void writeByte(ObjectOutputStream s)
throws IOException, ClassNotFoundException {
try {
s.defaultWriteObject(); //..............(*)
}
catch(NotActiveException e) {
e.printStackTrace();
}
s.writeObject(object);
}
public void readByte(ObjectInputStream s)
throws IOException, ClassNotFoundException {
s.defaultReadObject(); //..............(*)
Dummy x = (Dummy)s.readObject();
System.out.println(x.aNumber);
}
public static void main(
String args[]) {
try {
ObjectOutputStream oos = new ObjectOutputStream(
new FileOutputStream("file.txt"));
ObjectInputStream ois = new ObjectInputStream(
new FileInputStream("file.txt"));
Main main = new Main();
main.writeByte(oos);
main.readByte(ois);
}
catch(Exception e) {
e.printStackTrace();
}
}
}
class Dummy implements Serializable {
int aNumber = 100;
}