This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problems reading an object file

 
Micah Wedemeyer
Ranch Hand
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I keep getting the same exceptions when I attempt to read an object file.
If I'm correctly reading the stack trace, I'm getting an InvalidClassException followed by an IllegalAccessException. I don't know anything about either one.
I'm trying to write a List (an ArrayList) to a file, then read it back in. I write it as a List and attempt to read it (cast) as a List. If anyone has any ideas, please let me know.
Micah
java.io.InvalidClassException: com.sun.java.util.collections.AbstractList; IllegalAccessException
at java.io.ObjectInputStream.inputObject(ObjectInputStream.java)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java)
at com.dailyiowan.ontheline.OnTheLine.readChoiceList(OnTheLine.java)
at com.dailyiowan.ontheline.OnTheLine.doPost(OnTheLine.java)
at com.dailyiowan.ontheline.OnTheLine.doGet(OnTheLine.java)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:516)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:611)
at com.livesoftware.jrun.JRun.runServlet(JRun.java)
at com.livesoftware.jrun.JRunGeneric.handleConnection(JRunGeneric.java)
at com.livesoftware.jrunwebstar.JRunWebStar.HandleConnection(JRunWebStar.java)
 
Micah Wedemeyer
Ranch Hand
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HA HA, I noticed I am a now ranch hand. More like an outstretched hand begging to be saved!
 
Micah Wedemeyer
Ranch Hand
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anybody? Got any ideas?
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show us the code?
 
Micah Wedemeyer
Ranch Hand
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've decided not to mess around with writing the List. This seems to be the main problem. Instead, I'll try writing each element of the list to a file. When I read them back in, I'll reconstruct the list manually. Just to make sure, how do I read all objects in a file? Is it like this?
<code>
ObjectInputStream in = new ObjectInputStream(new FileInputStream("filename"));
Object o;
List a = new ArrayList();
while (o = in.readObject())
a.add(o);
</code>
I'm assuming, of course, that when it hits EOF then readObject will return null. Is this a valid assumption?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic