本文整理了Java中java.lang.System.setErr()
方法的一些代码示例,展示了System.setErr()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。System.setErr()
方法的具体详情如下:
包路径:java.lang.System
类名称:System
方法名:setErr
[英]Sets the standard error output stream to the given user defined output stream.
[中]将标准错误输出流设置为给定的用户定义输出流。
代码示例来源:origin: stackoverflow.com
private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
private final ByteArrayOutputStream errContent = new ByteArrayOutputStream();
@Before
public void setUpStreams() {
System.setOut(new PrintStream(outContent));
System.setErr(new PrintStream(errContent));
}
@After
public void cleanUpStreams() {
System.setOut(null);
System.setErr(null);
}
代码示例来源:origin: stanfordnlp/CoreNLP
/**
* Restores System.out and System.err to their original values
*/
protected static void restoreSystemStreams(){
System.setOut(realSysOut);
System.setErr(realSysErr);
}
代码示例来源:origin: eclipse-vertx/vert.x
public void terminate() {
if (System.err != ORIGINAL_ERR) {
System.setErr(ORIGINAL_ERR);
}
}
代码示例来源:origin: eclipse-vertx/vert.x
public void stop() {
if (System.err != ORIGINAL_ERR) {
System.setErr(ORIGINAL_ERR);
}
}
代码示例来源:origin: neo4j/neo4j
@Override
PrintStream replace( PrintStream replacement )
{
PrintStream old = java.lang.System.err;
java.lang.System.setErr( replacement );
return old;
}
};
代码示例来源:origin: eclipse-vertx/vert.x
public void stop() {
if (System.out != originalOutputPrintStream) {
System.setOut(originalOutputPrintStream);
}
if (System.err != originalErrorPrintStream) {
System.setErr(originalErrorPrintStream);
}
}
代码示例来源:origin: apache/flink
private static void restoreStdOutAndStdErr() {
System.setOut(stdOut);
System.setErr(stdErr);
}
代码示例来源:origin: gocd/gocd
private static void redirectStdOutAndErr() {
try {
PrintStream out = new PrintStream(new FileOutputStream(getOutFile(), true), true);
System.setErr(out);
System.setOut(out);
} catch (FileNotFoundException ignore) {
// cannot redirect out and err to file, so we don't
log("Unable to redirect stdout/stderr to file " + getOutFile() + ". Will continue without redirecting stdout/stderr.");
ignore.printStackTrace();
}
}
代码示例来源:origin: eclipse-vertx/vert.x
public void start() {
error.reset();
System.setErr(new PrintStream(error));
}
代码示例来源:origin: eclipse-vertx/vert.x
public void record() {
os = new PrintStream(output);
err = new PrintStream(error);
System.setOut(os);
System.setErr(err);
}
代码示例来源:origin: apache/flink
private static void replaceStdOutAndStdErr() {
stdOut = System.out;
stdErr = System.err;
buffer = new ByteArrayOutputStream();
PrintStream capture = new PrintStream(buffer);
System.setOut(capture);
System.setErr(capture);
}
代码示例来源:origin: apache/flink
@After
public void tearDown() {
if (System.out != originalSystemOut) {
System.out.close();
}
if (System.err != originalSystemErr) {
System.err.close();
}
System.setOut(originalSystemOut);
System.setErr(originalSystemErr);
}
代码示例来源:origin: apache/flink
@Before
public void setUp() {
System.setOut(new PrintStream(arrayOutputStream));
System.setErr(new PrintStream(arrayErrorStream));
}
代码示例来源:origin: apache/flink
protected static void resetStreamsAndSendOutput() {
System.setOut(ORIGINAL_STDOUT);
System.setErr(ORIGINAL_STDERR);
System.setIn(ORIGINAL_STDIN);
LOG.info("Sending stdout content through logger: \n\n{}\n\n", outContent.toString());
LOG.info("Sending stderr content through logger: \n\n{}\n\n", errContent.toString());
}
代码示例来源:origin: apache/flink
@Before
public void setUp() {
System.setOut(new PrintStream(arrayOutputStream));
System.setErr(new PrintStream(arrayErrorStream));
}
代码示例来源:origin: apache/flink
@Before
public void redirectStreams() {
this.out = System.out;
this.err = System.err;
OutputStream discards = new OutputStream() {
@Override
public void write(int b) {}
};
System.setOut(new PrintStream(discards));
System.setErr(new PrintStream(discards));
}
代码示例来源:origin: apache/flink
@After
public void tearDown() {
if (System.out != originalSystemOut) {
System.out.close();
}
if (System.err != originalSystemErr) {
System.err.close();
}
System.setOut(originalSystemOut);
System.setErr(originalSystemErr);
}
代码示例来源:origin: apache/zookeeper
@After
public void tearDown() throws IOException {
System.setOut(System.out);
System.setErr(System.err);
mySnapDir.setWritable(true);
FileUtils.deleteDirectory(mySnapDir);
}
代码示例来源:origin: gocd/gocd
@After
public void tearDown() throws Exception {
System.setErr(originalErr);
System.setOut(originalOut);
}
代码示例来源:origin: apache/zookeeper
@Before
public void setUp() throws IOException {
System.setOut(new PrintStream(outContent));
System.setErr(new PrintStream(errContent));
File snapDir = new File(testData, "invalidsnap");
mySnapDir = ClientBase.createTmpDir();
FileUtils.copyDirectory(snapDir, mySnapDir);
}
内容来源于网络,如有侵权,请联系作者删除!