wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes  invalid stream header: 426F6172 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark " invalid stream header: 426F6172" Watch " invalid stream header: 426F6172" New topic
Author

invalid stream header: 426F6172

Rob Brew
Ranch Hand

Joined: Jun 23, 2011
Posts: 99
Hi all.

I'm running a client server architecture to send an objectOutputStream to the client. I get :

java.io.StreamCorruptedException: invalid stream header: 426F6172

I've googled this but cannot see an answer, here is the networking code:


and the client:


Thank you all in advance.

Rob.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14117
    
  16

On the sending side, you're using a PrintWriter to write to the output stream.

On the receiving side, you're using an ObjectInputStream to read.

These two I/O classes don't go together. An ObjectInputStream expects data in a specific binary format. A PrintWriter writes text. Either use an ObjectOutputStream on the sending side, or use a Reader on the reading side and parse the data appropriately.

Java has two kinds of I/O classes. Streams are for reading and writing binary data (bytes). Readers and Writers are for reading and writing text (characters), which are converted from and to bytes using a character encoding.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: invalid stream header: 426F6172