Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

How can I know how many bytes had been received from an InputStream?

Thread view: 
maurora - 26 Nov 2006 07:00 GMT
Hi all,

I use KXML to parser xml file (InputStream) by TCP protocol. I want to
display the percent of received bytes of the whole xml file. But I
cannnot find any method in InputStream or KXML which can tell me that
data.

Thank you very much for your help.

Sincerely,
Maurora
Andrew Thompson - 26 Nov 2006 07:15 GMT
...
> I use KXML ..

Do you mean this one?  <http://kxml.sourceforge.net/>

I saw one link that suggested it was geared to
J2ME - though I cannot see 'J2Me' on the
sourceforge page.  Is it oriented to J2ME?

(If it is that one, note they have a mailing list amongst
the links on the left - might be a good place for more
specialised help.)

Andrew T.
sgoo - 26 Nov 2006 15:23 GMT
Haven't played with this KXML. Does it have a constructor that takes an
InputStream type as an argument? If so, you can create your own version
of CountingBytesInputStream which acts as a filter. Something like
this:

class CountingBytesInputStream extends FilterInputStream {
   ... // implements methods that call super's methods
   int getCount() {
       ...
   }
}

Then you can call:
   CountingBytesInputStream cbis = new
CountingBytesInputStream(inStream);
   KXML k = new KXML(cbls);
   ....
   System.err.println(clbs.getCount());

You can even add a callback into this class. For example, the
constructor can be
   CountingBytesInputStream(Updater u, InputStream stream) {
       this.updater = u;
   }

And then you can call it in the overriden read methods like this
   int read(...) {
       .....
       if (count % 1024 == 0) updater.notify(count);
   }


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.