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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark " invalid stream header: 426F6172" Watch " invalid stream header: 426F6172" New topic

invalid stream header: 426F6172

Rob Brew
Ranch Hand

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

I'm running a client server architecture to send an objectOutputStream to the client. I get : 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.

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15099

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 8 API documentation
I agree. Here's the link:
subject: invalid stream header: 426F6172
jQuery in Action, 3rd edition