• Post Reply Bookmark Topic Watch Topic
  • New Topic

ProgressMonitorInputStream and ObjectInputStream

 
David Irwin
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to use the ProgressMonitorInputStream to monitor the transfer of data of a ObjectInputStream? All the examples I have scene include a filtered input stream (which I don't believe ObjectInputStream is a subclass of). Any ideas? Thanks.
 
sander hautvast
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java api doc says constructor takes an InputStream, subclass of which is ObjectInputStream.
 
David Irwin
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya, I have no problem setting up the object stream and communicating over it using the following code:

Socket socket = new Socket("127.0.0.1", 2200);
InputStream istream = socket.getInputStream();
ProgressMonitorInputStream pmis =
new ProgressMonitorInputStream(this, "Reading object", istream);
ObjectInputStream obj_in = new ObjectInputStream(pmis);

When the code runs and I connect with a the server, I can successfully transfer objects. However, I noticed that the available() method always returns a 0 (istream.available(), pmis.available(), or obj_in.available()). This is a problem as the ProgressMonitorInputStream class depends on the stream returning an integer other than 0 when the available() method is called.

Any other ideas?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!