• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Read a PrintStream!

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, did I a search here but no real luck.

I have this class that as one of the parameters accepts a PrintStream (apparently, since the example uses System.out, which is a PrintStream obj).

Now, how do I read this PrintStream obj? The idea here is ofcource not to use System.out, but an object from where I can then examine the text that is written there and use that in some way, instead of just showing it in the console.

I have checked the API, but dont really find anything usefull. I bet there is a way, but I cant find it.

Thanks,
Ace
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
recheck api
 
Daniel Akesson
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Um, ok... but cant you give me some hints?
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't read from a PrintStream. PrintStreams are for performing output. The PrintStream may, however, wrap some other stream (i.e. PipedOutputStream,ByteArrayOutputStream) which you may obtain an InputStream from. You may have to fill in some details for us to give you constructive advice.
 
Daniel Akesson
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the main problem I did was that the OutObj must have the opposite InObj to work... So, I read same as is written. Anyway, I used ByteArrayOutputStream and ByteArrayInputStream(BOutStream.toByteArray()...) to read that.

Thanks anyway,
Daniel
 
Their achilles heel is the noogie! Give them noogies tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic