InputStream problem
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   flo_goss
Posted On:   Friday, March 14, 2003 05:02 AM


First I open an OutputStream like that :



PrintStream ps = new PrintStream(socket.getOutputStream());


Then I try to get an ObjectInputStream on the same object :


ObjectInputStream in = new ObjectInputStream(socket.getInputStream());



But when I try to read the object on the InputStream I get an exception :



invalid stream header



Why ? Does anybody knows how I can get an ObjectInputStream on the same object as I get a PrintStream ?


Thx

Re: InputStream problem

Posted By:   Pavel_Tavoda  
Posted On:   Thursday, March 27, 2003 06:48 AM

If you want use Object(input/output)Stream you have to use it on both sides. You can't write to stream via PrintStream and read via ObjectInputStream.
ObjectOutputStream is writing some important informations at begining to stream. This informations are required by ObjectInputStream.
About | Sitemap | Contact