Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with RandomAccessFile

 
Andreas Groscurth
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

can anyone tell my why I do get -1393754107 with this code instead of 1

 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because an ObjectOutputStream writes a header, too. Take a look at the size of the file that's been written - it's bigger than just the 4 bytes that writeInt() would give you. You really don't want to read this with anything other than an ObjectInputStream. Or in this case, if you're not going to use writeObject() and readObject() at some point, there's really no need to be using the ObjectOutput streams at all.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic