System.err.print 是报错专用输输出,有颜色标记,所有err打印的都在顶行输出
System.out.print 是标准输出,白底黑字
-
package iobuffer;
-
-
public class ErrOut {
-
public static void main(String argvs) {
-
System.err.println("有颜色的输出"); //是报错专用输输出,有颜色标记
-
-
System.out.println("我没有颜色"); //是标准输出,白底黑字
-
}
-
}
代码运行结果
原因二:
同System.out.print()没有本质区别,err是运行期异常和错误反馈的输出流的方向。
最直接的区别是,在控制台输出err是红色,比较醒目。
还有一个比较重要:
(1)System.out.println 能重定向到别的输出流,这样的话你在屏幕上将看不到打印的东西了,如输出到一个txt的log日志中.
(2)而System.err.println只能在屏幕上实现打印,即使你重定向了也一样。
最直接的区别是,在控制台输出err是红色,比较醒目。
还有一个比较重要:
(1)System.out.println 能重定向到别的输出流,这样的话你在屏幕上将看不到打印的东西了,如输出到一个txt的log日志中.
(2)而System.err.println只能在屏幕上实现打印,即使你重定向了也一样。