The Artima Developer Community
Sponsored Link

Java Answers Forum
losing an input stream after buffering it?

3 replies on 1 page. Most recent reply: Jan 15, 2003 1:54 AM by Antonas

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Paul Tomsic

Posts: 3
Nickname: ptomsic
Registered: Jan, 2003

losing an input stream after buffering it? Posted: Jan 14, 2003 10:56 AM
Reply to this message Reply
Advertisement
How do you retain a whole InputStream after you buffer it?


For instance, I need to get an InputStream, then pass it along to a method.
I need to re-reference that passed stream again (and again).


I've got the following:

InputStream is = t.getTemplate(); // t is an object that returns an InputStream, successfully
BufferedInputStream bais = new BufferedInputStream(is);
useMyStream(bais);
// here I need to re-use the return value from t.getTemplate()
// but when I call bais.available() it gives me 0 or says Stream is closed!


How do I reuse it after calling out to another local public method?
Thanks,
Paul


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: losing an input stream after buffering it? Posted: Jan 14, 2003 1:34 PM
Reply to this message Reply
It is not clear what useMyStream(bais); is doing. It could be closing the stream, for all we know.

Paul Tomsic

Posts: 3
Nickname: ptomsic
Registered: Jan, 2003

Re: losing an input stream after buffering it? Posted: Jan 14, 2003 4:28 PM
Reply to this message Reply
the stream is of an SVG, and I'm merely parsing it.

Antonas

Posts: 11
Nickname: tony
Registered: May, 2002

Re: losing an input stream after buffering it? Posted: Jan 15, 2003 1:54 AM
Reply to this message Reply
To reuse InputStream You can try to use mark(int) and
reset() methods of InputStream.

Flat View: This topic has 3 replies on 1 page
Topic: Inheritance Inner class super Previous Topic   Next Topic Topic: Import statement

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use