I have been searching this forum for a solution to my problem, but unfortunately couldn't find anything so far. It would be very kind if you could take a look at this.
I am trying to read an object, that I have saved before in a file called "eco.net", in an applet with the readObject() method:
Expand|Select|Wrap|Line Numbers
- import java.applet.*;
- import java.io.*;
- public class TestApplet extends Applet
- {
- public void init()
- {
- try{
- FileInputStream fis = new FileInputStream("eco.net");
- ObjectInputStream ois = new ObjectInputStream(fis);
- BioNet bioNet = (BioNet) ois.readObject();
- ois.close();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- }
- }
Expand|Select|Wrap|Line Numbers
- java.lang.StackOverflowError
- at java.io.ObjectInputStream$BlockDataInputStream.readByte(ObjectInputStream.java:2718)
- at java.io.ObjectInputStream.readHandle(ObjectInputStream.java:1428)
- at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1490)
- at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
- at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
- at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)
- at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
- at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
- at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1869)
- at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
- at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
- at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
- ...
If I try to read the same object in a normal application, this works flawlessly:
Expand|Select|Wrap|Line Numbers
- import java.io.*;
- public class Test
- {
- public static void main(String[] args)
- {
- try{
- FileInputStream fis = new FileInputStream("eco.net");
- ObjectInputStream ois = new ObjectInputStream(fis);
- BioNet bioNet = (BioNet) ois.readObject();
- ois.close();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- }
- }
A bit more information about the object that I am trying to read:
I am trying to create a Java-representation of a biochemical network "BioNet". This uses the classes "Compound" and "Reaction", which are themselves interlinked. Please tell me if it would help you to see the whole code (it is quite a lot, that's why I didn't post it already). The actual writing of the object in a file is done with this code:
Expand|Select|Wrap|Line Numbers
- import java.io.*;
- public class BuildBioNet {
- public static void main(String[] args) {
- try {
- FileOutputStream fos = new FileOutputStream("eco.net");
- ObjectOutputStream oos = new ObjectOutputStream(fos);
- BioNet eco = new BioNet();
- eco.buildFromFile("ecoInfo.ref","ecoBioNet.txt");
- oos.writeObject(eco);
- // Flush and close the ObjectOutputStream.
- oos.flush();
- oos.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Thank you very very much,any help is appreciated - this problem is driving me mad for days already.
Regards,
Kai