首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

相干System.out和System.err的源码

2011-11-26 
有关System.out和System.err的源码两个问题:1请教下System.err是怎么做到用红颜色字体输出的?2关于这两者

有关System.out和System.err的源码
两个问题:
    1     请教下System.err是怎么做到用红颜色字体输出的?
    2     关于这两者的源码问题:
          可以看到在System这个类中的out和err两个属性定义如下:
          public   final   static   PrintStream   out   =   nullPrintStream();
          public   final   static   PrintStream   err   =   nullPrintStream();

          nullPrintStream()方法定义如下:
          private   static   PrintStream   nullPrintStream()   throws   NullPointerException   {

                  if   (currentTimeMillis()   >   0)
        return   null;
throw   new   NullPointerException();
        }
        这里为什么直接返回一个null,如果这里返回是null的话,System.out和System.err是怎么工作的?
        谢谢

[解决办法]
System.out和System.err只是两个文件描述符,颜色的事情是由更上层的终端处理。

热点排行