473,396 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Can't set back System.out

Hi Folks,

I have tried to redirect system.out for a while and then set it back,
but it can't set it back as following program snapshot

ByteArrayOutputStream baos = new ByteArrayOutputStream();
System.setOut(new PrintStream(baos, true));
System.out.println("hello");
System.err.println(baos);
System.setOut(System.out);
System.out.println("after hello\n");
Only display "hello" in system.err and nothing in system .out
Regards,
FilexBB
Jul 17 '05 #1
4 8613
FilexBB wrote:
Hi Folks,

I have tried to redirect system.out for a while and then set it back,
but it can't set it back as following program snapshot

ByteArrayOutputStream baos = new ByteArrayOutputStream();
System.setOut(new PrintStream(baos, true));
System.out.println("hello");
System.err.println(baos);
System.setOut(System.out);
System.out.println("after hello\n");
Only display "hello" in system.err and nothing in system .out
Regards,
FilexBB

I had a similar problem:

int so = 0;

int x = 5;
so = x;
so = so;
and after that code... "so" is still 5. :-(
Jul 17 '05 #2
"Miguel De Anda" <sodamnmad@_hotmail_.com> wrote in message
news:40******************************@news.teranew s.com...
FilexBB wrote:
Hi Folks,

I have tried to redirect system.out for a while and then set it back,
but it can't set it back as following program snapshot

ByteArrayOutputStream baos = new ByteArrayOutputStream();
System.setOut(new PrintStream(baos, true));
System.out.println("hello");
System.err.println(baos);
System.setOut(System.out);
System.out.println("after hello\n");
Only display "hello" in system.err and nothing in system .out
Regards,
FilexBB

I had a similar problem:

int so = 0;

int x = 5;
so = x;
so = so;
and after that code... "so" is still 5. :-(

Is this even for real? What in the world would you expect?
Jul 17 '05 #3
On Fri, 19 Mar 2004 06:39:35 -0600, "Ryan Stewart"
<zz********@gSPAMo.com> wrote:
"Miguel De Anda" <sodamnmad@_hotmail_.com> wrote in message
news:40******************************@news.terane ws.com...
FilexBB wrote:
> Hi Folks,
>
> I have tried to redirect system.out for a while and then set it back,
> but it can't set it back as following program snapshot
>
> ByteArrayOutputStream baos = new ByteArrayOutputStream();
> System.setOut(new PrintStream(baos, true));
> System.out.println("hello");
> System.err.println(baos);
> System.setOut(System.out);
> System.out.println("after hello\n");
>
>
> Only display "hello" in system.err and nothing in system .out
>
>
> Regards,
> FilexBB

I had a similar problem:

int so = 0;

int x = 5;
so = x;
so = so;
and after that code... "so" is still 5. :-(


Is this even for real? What in the world would you expect?


Me suspects that he/she was demonstrating why the OP's code wasn't
working in a simpler way.

output = console
output = byteoutputstream
output = output

--
now with more cowbell
Jul 17 '05 #4
fi*****@yahoo.com.hk (FilexBB) wrote in message news:<70**************************@posting.google. com>...
Hi Folks,

I have tried to redirect system.out for a while and then set it back,
but it can't set it back as following program snapshot

ByteArrayOutputStream baos = new ByteArrayOutputStream();
System.setOut(new PrintStream(baos, true));
System.out.println("hello");
System.err.println(baos);
System.setOut(System.out);
System.out.println("after hello\n");
Only display "hello" in system.err and nothing in system .out
Regards,
FilexBB System.setOut(System.out);

This System.out is still reassigned to baos-printstream.
Do the following:

PrintStream ps = System.out; //backup
......
System.setOut(ps); //restore
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Alan Wang | last post by:
Hi there, I am having a problem with my asp.net web pages. If user hit BACK button on IE and then click some other web controls on the web page. the page goes to blank page. Anyone has the...
3
by: Chi | last post by:
what is the "unable to write data to the transport connection" I use the oreilly , programming c# using System; using System.Net.Sockets; using System.Text; using System.IO; // get a file...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
3
by: Siv | last post by:
Hi, A little while ago I wrote a small program that allowed the user to view products from a database. The database holds the details of the products which can be viewed via a form and...
11
by: bill | last post by:
I dynamically create buttons and associate them with an event using AddHandler. I want all the button events to fire at one time, when the page is posted, instead of when each button is clicked....
13
by: Marc | last post by:
The first part of the below writes the name and location of all buttons on a from to a text file. The second part reads that information back in and recreates the buttons. My problem is reading...
3
by: RallyDSM | last post by:
Pre STory - I've had a lot of problems with this program, and I just added the last part of it (the add item code) and now an older part of the program crashes. Public Structure Stocks Public...
2
by: pallaw | last post by:
Hello All, My web Client is using a COM component with connection point enabled.my client is getting call back from this component.now I have to update a text control in handler of this...
1
by: =?Utf-8?B?SkI=?= | last post by:
Hello My pgm1 (User Interface Level) passes an empty ArrayList to pgm2 (Business Logic Level). pgm2 then calls pgm3 (Data Access Level) to populate the ArrayList. Question1: When pgm2 gets...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.