zoukankan      html  css  js  c++  java
  • System.out.println()的详解

    System是System类

    1 package java.lang;
    2 public final class System {
    3       public final static PrintStream out = null;
    4 }

    println()是PrintStream 类中的方法。

    package java.io;
    public class PrintStream extends FilterOutputStream
        implements Appendable, Closeable
    {
      
       protected OutputStream out;

       private BufferedWriter textOut;

        private void ensureOpen() throws IOException {
           if (out == null)
            throw new IOException("Stream closed");
        }

       
    public void println() { newLine();//换行 } public void println(boolean x) { synchronized (this) { print(x); newLine(); } } public void println(String x) { synchronized (this) { print(x); newLine(); } } public void print(boolean b) { write(b ? "true" : "false"); } public void print(Object obj) { write(String.valueOf(obj)); } private void write(String s) { try { synchronized (this) { ensureOpen(); textOut.write(s); textOut.flushBuffer(); charOut.flushBuffer(); if (autoFlush && (s.indexOf(' ') >= 0)) out.flush(); } } catch (InterruptedIOException x) { Thread.currentThread().interrupt(); } catch (IOException x) { trouble = true; } } private void newLine() { try { synchronized (this) { ensureOpen(); textOut.newLine(); textOut.flushBuffer(); charOut.flushBuffer(); if (autoFlush) out.flush(); } } catch (InterruptedIOException x) { Thread.currentThread().interrupt(); } catch (IOException x) { trouble = true; } } }
  • 相关阅读:
    Js中的正则表达式
    js内存泄露的几种情况
    JavaScript的setTimeout与setInterval执行时机
    IE模拟addDOMLoadEvent和jQuery的ready实现
    谈谈JavaScript的异步实现
    在iOS7中修改状态栏字体的颜色
    IOS 疯狂基础之 页面间跳转
    ATL2.1版的CString分析
    翻译: 如何改变MFC应用程序主窗口的类名
    VC5.0中的ATL的一个有趣的bug
  • 原文地址:https://www.cnblogs.com/stujike/p/9688054.html
Copyright © 2011-2022 走看看