• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

help in NotActiveException

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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;
}
 
I need a new interior decorator. This tiny ad just painted every room in my house purple.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic