I/O Streams
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Saturday, September 29, 2001 10:47 PM

Hi Guy's !!! A "User-Defined Object" or a "String Object" is passed from the server to the Client.On the client-side,how should it be determined which type of object has been passed. For Instance,if a String object is passed then InputStream in = new BufferedReader(new InputStreamReader(....)) and readLine() would be used. However,when a user-defined object is passed then ObjectInputStream() and readObject() would be used to obtain the data. How should the type of object passed in the stream be determined ? Pls suggest. Thanks Guy's    More>>

Hi Guy's !!!


A "User-Defined Object" or a "String Object" is passed from the server to the Client.On the client-side,how should it be determined which type of object has been passed.


For Instance,if a String object is passed then
InputStream in = new BufferedReader(new InputStreamReader(....))
and readLine() would be used.


However,when a user-defined object is passed then
ObjectInputStream() and
readObject() would be used to obtain the data.



How should the type of object passed in the stream be determined ?


Pls suggest.

Thanks Guy's

   <<Less

Re: I/O Streams

Posted By:   Bogdan_Sheptunov  
Posted On:   Monday, October 1, 2001 09:53 AM

Get an instance of ObjectInputStream, and do something like


Object result = in.readObject();
if (result instanceof String)
{
// handle your string
}
else if (result instanceof BlahBlahBlah)
{
// handle your own type
}
else
{
// handle unknown types
}
About | Sitemap | Contact