Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

help in NotActiveException  RSS feed

 
ranj nambiar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;
}
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!