Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

ProgressMonitorInputStream and ObjectInputStream

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
We've gotta get close enough to that helmet to pull the choke on it's engine and flood his mind! Or, we could just read this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic