📄 redirectiondemo.java
字号:
import java.io.PrintStream;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
public class RedirectionDemo
{
public static void main(String[] args)
{
PrintStream errStream = null;
try
{
errStream =
new PrintStream(
new FileOutputStream("errormessages.txt"));
}
catch(FileNotFoundException e)
{
System.out.println(
"Error opening file with FileOutputStream.");
System.exit(0);
}
System.setErr(errStream);
System.err.println("Hello from System.err.");
System.out.println("Hello from System.out.");
System.err.println("Hello again from System.err.");
errStream.close( );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -