This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes Problem with RandomAccessFile Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Problem with RandomAccessFile" Watch "Problem with RandomAccessFile" New topic

Problem with RandomAccessFile

Andreas Groscurth

Joined: Mar 08, 2004
Posts: 12

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

Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
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.

"I'm not back." - Bill Harding, Twister
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Problem with RandomAccessFile
It's not a secret anymore!