consecutive printwriters on the same outputstream

A

Andy Fish

Hi,

Is it possible to open two different printWriters (say pw1 and pw2) on the
same outputStream

I want to use pw1 to write some output, then pw2.

Andy
 
D

Dobromir Gaydarov

Andy Fish said:
Hi,

Is it possible to open two different printWriters (say pw1 and pw2) on the
same outputStream

Sure, why not.
I want to use pw1 to write some output, then pw2.

You probably want to see who much will the 2 thing get mixed up, don't you?
I can not imagine any benefit of doing it this way, but you almost certainly
will run into troubles.

Dobromir
 
N

nos

isn't this like mixing your normal output stream with the error
output stream so you can later tell where the problems are?
maybe you can look at System.setOut() and System.setErr()
to see how they do it there
 
T

Tor Iver Wilhelmsen

Andy Fish said:
Is it possible to open two different printWriters (say pw1 and pw2) on the
same outputStream

Yes. But you need to keep in mind that closing pw1 will also close the
stream pw2 is connected to.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top