• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

invalid stream header: 426F6172

 
Rob Brew
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15354
39
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic