473,609 Members | 1,818 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reassign standard Output Stream.

dmjpro
2,476 Top Contributor
Today I came across a thing, is it possible to change the Standard Output Stream?
Then I immediately went for assign the System.out variable.

Expand|Select|Wrap|Line Numbers
  1. System.out = new PrintStream(new File("some_file_name"));
  2.  
Then I got a message, the final variable not to be updated.

Then I came to know that I have to take help from API,
Expand|Select|Wrap|Line Numbers
  1. System.setOut(new PrintStream(new File("")))
So how Java updates the System.out as it's final.
Please help me to know it.

Kind regards,
Dmjpro.
Sep 26 '07 #1
27 4085
r035198x
13,262 MVP
Today I came across a thing, is it possible to change the Standard Output Stream?
Then I immediately went for assign the System.out variable.

Expand|Select|Wrap|Line Numbers
  1. System.out = new PrintStream(new File("some_file_name"));
  2.  
Then I got a message, the final variable not to be updated.

Then I came to know that I have to take help from API,
Expand|Select|Wrap|Line Numbers
  1. System.setOut(new PrintStream(new File("")))
So how Java updates the System.out as it's final.
Please help me to know it.

Kind regards,
Dmjpro.
Java does not change the System.out at all.
What makes you think that it changes it?
Sep 26 '07 #2
JosAH
11,448 Recognized Expert MVP
Java does not change the System.out at all.
What makes you think that it changes it?
Duh, that System class is full of native methods and stuff; it even uses a
sun.misc.Shared Secrets class for several purposes; I don't trust that class
one single bit ;-)

kind regards,

Jos
Sep 26 '07 #3
r035198x
13,262 MVP
Duh, that System class is full of native methods and stuff; it even uses a
sun.misc.Shared Secrets class for several purposes; I don't trust that class
one single bit ;-)

kind regards,

Jos
Version 6? My 1.5.0_03 uses no such secrets.
I
Sep 26 '07 #4
JosAH
11,448 Recognized Expert MVP
Version 6? My 1.5.0_03 uses no such secrets.
I
Yup; check your src.zip that comes with the jdk; that class is full of it.

kind regards,

Jos
Sep 26 '07 #5
r035198x
13,262 MVP
Yup; check your src.zip that comes with the jdk; that class is full of it.

kind regards,

Jos
I'm sticking with 1.5 for my current project.
I'd like to find time and look to see what those guys were doing with a secrets class though.
Sep 26 '07 #6
JosAH
11,448 Recognized Expert MVP
I'm sticking with 1.5 for my current project.
I'd like to find time and look to see what those guys were doing with a secrets class though.
They don't want us to know that, it's a class in the sun.misc package and they
don't give source for any class in those packages; they're 'SharedSecrets' .

kind regards,

Jos
Sep 26 '07 #7
Nepomuk
3,112 Recognized Expert Specialist
They don't want us to know that, it's a class in the sun.misc package and they
don't give source for any class in those packages; they're 'SharedSecrets' .

kind regards,

Jos
Reminds me of this issue, but I'd better keep that to myself... ;-)

Greetings,
Nepomuk
Sep 26 '07 #8
JosAH
11,448 Recognized Expert MVP
Reminds me of this issue, but I'd better keep that to myself... ;-)

Greetings,
Nepomuk
It doesn't matter much: real men (like me) read octal or hex dumps anyway ;-)

kind regards,

Jos (aka 004a006f0073 (big endian unicode) ;-)
Sep 26 '07 #9
r035198x
13,262 MVP
It doesn't matter much: real men (like me) read octal or hex dumps anyway ;-)

kind regards,

Jos (aka 004a006f0073 (big endian unicode) ;-)
Oh yeah, there is always a legal way of reconstructing someone's source code even though the source code is supposed to be "private".
Sep 26 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

12
3197
by: Matt Garman | last post by:
I'd like to create a "custom output facility". In other words, I want an object whose use is similar to std::cout/std::cerr, but offers more flexibility. Instead of simply writing the parameter to stdout/stderr, I'd like it to write to stdout, to a file, and/or call a logging function. So my output function might look something like this: OutputFacility& OutputFacility::put(const std::string& s) { cout << s; // print to stdout
3
5890
by: gouki | last post by:
suppose i have a class: class X { int i; string out; } X::out = "object x";
7
2332
by: Steven T. Hatton | last post by:
I haven't looked very closely, but from what I'm seeing, it looks like there are no buffered I/O streams in the Standard Library. There are stream buffers, but not buffered streams. I don't have an excellent definition of what a buffered stream is right off the top of my head, but it's something like a cache that can hold data from the source, or for the destination that can't be immediately processed. Say, for example, if you are...
1
10134
by: Googler | last post by:
What does the standard say about snwprintf in the following cases ? For wchar_t s; snwprintf(s,5,L"Hello"); I know the return value should indicate error. (eg. -1)
16
3480
by: ben beroukhim | last post by:
I have huge number of legacy code which use standard files functions. I would like to pass a memory pointer rather than a FILE pointer. I am trying to use FILEs in the code to refer to memory buffers. Basically, I want to be able to use all the standard read and write functions, but I want them to refer to memory locations, rather than disk files. I do not want to touch the legacy code. Does any one know of a library
9
3989
by: kernelxu | last post by:
hi,everybody. I calling function setbuf() to change the characteristic of standsrd input buffer. some fragment of the progrem is: (DEV-C++2.9.9.2) #include <stdio.h> #include <stdlib.h> int main(void) { char buf = {0};
6
1515
by: Seenivasan Palaniappan | last post by:
I heard people saying when executing a program 3 standard files will be opened namely STDIN, STDOUT, STDERR. Is it so? if so what is the purpose and what each of them stands for? Explanation of the concept, Guidence to / provision of resources will be of great help. Regards, PL.Seenivasan
0
1843
by: lini | last post by:
Hello, I am writing some code in the scenario which can be described as follow: + program A which writes to standard output (e.g. cout >> whatever). + program B which has GUI and also listens to the standart input regularly (using a timer) if there is no input, it returns to the GUI and does something else. What I expect is B should work without problem in both cases: (1) user@host $ A | B (2) user@host $ B In B's code, I tried...
1
3307
by: terminatorul | last post by:
Hello Sorry if asking a known question. I have a program that reads lines of text from standard input and writes the non-empty ones back to standard output. In most cases it will be used with standard input and output streams redirected to FS files. If my input is wide-character (UNICODE) I would like to use wcin and wcout and write wide-character text to standard output. If my input is
0
8573
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8547
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8224
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8406
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7013
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6062
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5517
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4026
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
1393
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.