avatar
申请访问学者# Engineering - 工程
d*c
1
因为用户可以redirect standard output,那在java程序里面怎么知道任意时刻System
.out是指向哪里。
谢谢。
avatar
C*3
2
国内一好友,目前大学副教授,正在积极寻找计算机、自动化、电子工程等领域的美国
访问学者的交流机会,他尤其精通软件开发和自动化硬件设计。
如果您或朋友正有此机会,请私信我,或者联系西南大学杨教授
[email protected]
/* */
MOBILE(86) 1388-3737-789
谢谢
avatar
C*3
4
补充一下:自带经费

/* */

【在 C****3 的大作中提到】
: 国内一好友,目前大学副教授,正在积极寻找计算机、自动化、电子工程等领域的美国
: 访问学者的交流机会,他尤其精通软件开发和自动化硬件设计。
: 如果您或朋友正有此机会,请私信我,或者联系西南大学杨教授
: [email protected]
: /* */
: MOBILE(86) 1388-3737-789
: 谢谢

avatar
d*c
5
谢谢回答。
但这不是我的问题。我知道java如何redirect System.out,问题是如何用程序来知道
System.out指向哪里。
用伪代码来说明我的问题:
PrintStream ps = System.getOut();
if (ps instance of ConsoleStream)
{
// it is default stdout
}
else if (ps instance of FileOutputStream)
{
// find its file name/full path
}
else if (ps instance of Some-Other-Kind-Of-Output-Stream)
{
// find its storage
}
else
...

【在 m*****u 的大作中提到】
: http://www.google.com/search?aq=f&sourceid=chrome&ie=UTF-8&q=re
:
: System

avatar
d*c
6
自顶一下。
呼唤高手。

【在 d**c 的大作中提到】
: 谢谢回答。
: 但这不是我的问题。我知道java如何redirect System.out,问题是如何用程序来知道
: System.out指向哪里。
: 用伪代码来说明我的问题:
: PrintStream ps = System.getOut();
: if (ps instance of ConsoleStream)
: {
: // it is default stdout
: }
: else if (ps instance of FileOutputStream)

avatar
r*l
7
To answer your question directly, see the attachment.
However, you are stuck at FileOutputStream. Stdout is also a file.
I would not recommend to branch your code based on System.out type.
You probably can use log4j and write your own appender to do the job.

【在 d**c 的大作中提到】
: 自顶一下。
: 呼唤高手。

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。