代理getOutputStream,真正write的时候才获取
162574
public ServletOutputStream getOutputStream() throws IOException {
        return new ServletOutputStream() {
            protected OutputStream proxy;
            public void write(int b) throws IOException {
                if (proxy == null)
                    proxy = getResponse().getOutputStream();
                proxy.write(b);
            }
            
            public void write(byte[] paramArrayOfByte, int off, int len)
                    throws IOException {
                if (proxy == null)
                    proxy = getResponse().getOutputStream();
                proxy.write(paramArrayOfByte, off, len);
            }
        };
    }
120228
@Override
    public OutputStream getOutputStream() throws IOException {

	URLConnection connection = url.openConnection();
	if (connection == null) return null;

	connection.setDoOutput(true); // is it necessary?
	return connection.getOutputStream();
    }
257810
public final PrintWriter getWriter() throws IOException {
        if (out == null) {
            // NOTE: getCharacterEncoding may/should not return null
            OutputStream out = createOutputStream();
            String charEncoding = response.getCharacterEncoding();
            this.out = new PrintWriter(charEncoding != null ? new OutputStreamWriter(out, charEncoding) : new OutputStreamWriter(out));
        }
        else if (out instanceof ServletOutputStream) {
            throw new IllegalStateException("getOutputStream() already called.");
        }

        return (PrintWriter) out;
    }
549031
public static OutputStreamWriter getWriter(OutputStream out, Charset charset) {
		if (null == out) {
			return null;
		}

		if (null == charset) {
			return new OutputStreamWriter(out);
		} else {
			return new OutputStreamWriter(out, charset);
		}
	}
1339488
public synchronized OutputStream getOutputStream(int stream) {
    if (!output.containsKey(stream)) {
      output.put(stream, new WebSocketOutputStream(stream));
    }
    return output.get(stream);
  }
584668
public byte[] getWriterBytes() {

        if (isSuspended()) {
            // No output whatsoever if the response is suspended
            return new byte[0];
        }
        if (m_cacheBytes != null) {
            // Optimization for cached "leaf" nodes, here I re-use the array from the cache
            return m_cacheBytes;
        }
        if (m_out == null) {
            // No output was written so far, just return an empty array
            return new byte[0];
        }
        if (m_writer != null) {
            // Flush the writer in case something was written on it
            m_writer.flush();
        }
        return m_out.getBytes();
    }
1314092
function stream(out, err) {
  if(!err) err = out;

  if(typeof out === 'string') {
    this._out = fs.createWriteStream(out);
  }else{
    this._out = out;
  }

  if(typeof err === 'string') {
    this._err = fs.createWriteStream(err);
  }else{
    this._err = err;
  }

  if((!(this._out instanceof Writable)
      && this._out !== process.stdout)
    || (!(this._err instanceof Writable)
      && this._err !== process.stderr)) {
    throw new Error('invalid log stream');
  }
}
1243915
public int write(OutputStreamWithBuffer os, char []cbuf, int off, int len)
    throws IOException
  {
    for (int i = 0; i < len; i++) {
      char ch = cbuf[off + i];

      if (ch < 0x80)
        os.write(ch);
      else {
        os.write('\\');
        os.write('u');

        int b = (ch >> 12) & 0xf;
        os.write(b < 10 ? b + '0' : b + 'a' - 10);
        b = (ch >> 8) & 0xf;
        os.write(b < 10 ? b + '0' : b + 'a' - 10);
        b = (ch >> 4) & 0xf;
        os.write(b < 10 ? b + '0' : b + 'a' - 10);
        b = ch & 0xf;
        os.write(b < 10 ? b + '0' : b + 'a' - 10);
      }
    }
    
    return len;
  }
476344
@GwtIncompatible("Unnecessary")
  private Writer streamToLegacyOutputWriter(OutputStream stream) throws IOException {
    if (legacyOutputCharset == null) {
      return new BufferedWriter(new OutputStreamWriter(stream, UTF_8));
    } else {
      return new BufferedWriter(
          new OutputStreamWriter(stream, legacyOutputCharset));
    }
  }
1334014
private InputStream getInputStream(String url) throws Exception {
        HttpGet getMethod = new HttpGet(url);
        DefaultHttpClient client = new DefaultHttpClient(m_cManager);
        client.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, TIMEOUT_SECONDS * 1000);
        UsernamePasswordCredentials creds = getCreds(url);
        if (creds != null) {
            client.getCredentialsProvider().setCredentials(AuthScope.ANY, creds);
            client.addRequestInterceptor(new PreemptiveAuth());
        }
        client.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, true);
        HttpInputStream in = new HttpInputStream(client, getMethod);
        if (in.getStatusCode() != 200) {
            try {
                in.close();
            } catch (Exception e) {
            }
            throw new IOException("HTTP request failed.  Got status code "
                    + in.getStatusCode()
                    + " from remote server while attempting to GET " + url);
        } else {
            return in;
        }
    }
1171217
public ServletOutputStream getOutputStream() {
        final boolean isTraceOn = com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled();
        if (isTraceOn&&logger.isLoggable (Level.FINE))  //306998.15
            logger.entering(CLASS_NAME,"getOutputStream","gotWriter="+String.valueOf(_gotWriter)+" ["+this+"]");

        if (!_ignoreStateErrors && _gotWriter) {

            if (isTraceOn&&logger.isLoggable (Level.FINE))  //306998.15
                logger.exiting(CLASS_NAME,"getOutputStream","throw IllegalStateException");

            throw new IllegalStateException(nls.getString("Writer.already.obtained", "Writer already obtained"));
        }

        //PK89810 Start
        if(!(WCCustomProperties.FINISH_RESPONSE_ON_CLOSE) || ! _gotOutputStream)                
        {
            _gotOutputStream = true;

            // LIBERTY _bufferedOut.init(_rawOut, getBufferSize());
            // LIBERTY _bufferedOut.setLimit(_contentLength);
            // LIBERTY _bufferedOut.setResponse(_response);
            // LIBERTY _responseBuffer = _bufferedOut;
        } //PK89810 End
        this.fireOutputStreamRetrievedEvent(_bufferedOut);

        if (isTraceOn&&logger.isLoggable (Level.FINE))  //306998.15
            logger.exiting(CLASS_NAME,"getOutputStream");

        return _bufferedOut;
    }
672610
@Override
    public PrintWriter getWriter() throws IOException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "getWriter: " + this);
        }
        if (this.streamActive) {
            throw new IllegalStateException("Output stream already obtained");
        }
        if (null == this.outWriter) {
            this.outWriter = new PrintWriter(
                            new OutputStreamWriter(
                                            this.outStream, getCharacterEncoding()), false);
        }
        return this.outWriter;
    }
15358
public void getThreadDump(OutputStream out) {
    final ThreadInfo[] threads = this.threads.dumpAllThreads(true, true);
    final PrintWriter writer = new PrintWriter(out, true);

    for (int ti = threads.length - 1; ti >= 0; ti--) {
      final ThreadInfo t = threads[ti];
      writer.printf("%s id=%d state=%s",
        t.getThreadName(),
        t.getThreadId(),
        t.getThreadState());

      final LockInfo lock = t.getLockInfo();
      if ((lock != null) && (t.getThreadState() != State.BLOCKED)) {
        writer.printf("\n    - waiting on <0x%08x> (a %s)",
          lock.getIdentityHashCode(),
          lock.getClassName());
        writer.printf("\n    - locked <0x%08x> (a %s)",
          lock.getIdentityHashCode(),
          lock.getClassName());
      } else if ((lock != null) && (t.getThreadState() == State.BLOCKED)) {
        writer.printf("\n    - waiting to lock <0x%08x> (a %s)",
          lock.getIdentityHashCode(),
          lock.getClassName());
      }

      if (t.isSuspended()) {
        writer.print(" (suspended)");
      }

      if (t.isInNative()) {
        writer.print(" (running in native)");
      }

      writer.println();
      if (t.getLockOwnerName() != null) {
        writer.printf("     owned by %s id=%d\n", t.getLockOwnerName(), t.getLockOwnerId());
      }

      final StackTraceElement[] elements = t.getStackTrace();
      final MonitorInfo[] monitors = t.getLockedMonitors();

      for (int i = 0; i < elements.length; i++) {
        final StackTraceElement element = elements[i];
        writer.printf("    at %s\n", element);
        for (int j = 1; j < monitors.length; j++) {
          final MonitorInfo monitor = monitors[j];
          if (monitor.getLockedStackDepth() == i) {
            writer.printf("      - locked %s\n", monitor);
          }
        }
      }
      writer.println();

      final LockInfo[] locks = t.getLockedSynchronizers();
      if (locks.length > 0) {
        writer.printf("    Locked synchronizers: count = %d\n", locks.length);
        for (LockInfo l : locks) {
          writer.printf("      - %s\n", l);
        }
        writer.println();
      }
    }

    writer.println();
    writer.flush();
  }
1192961
private BufferedWriter getTextOut() {
        if (textOut == null) {
            PrintStream proxy = WeakProxy.forObject(this);
            charOut = charset != null ? new OutputStreamWriter(proxy, charset) :
                    new OutputStreamWriter(proxy);
            textOut = new BufferedWriter(charOut);
        }
        return textOut;
    }
728939
public OutputStream asOutputStream() {
		OutputStream out = new OutputStream() {

			@Override
			public final void write(int b) {
				sendData(new byte[] { (byte) b });
			}

			@Override
			public final void write(byte[] b) {
				write(b, 0, b.length);
			}

			@Override
			public final void write(byte[] b, int off, int len) {
				byte[] copy = new byte[len];
				System.arraycopy(b, 0, copy, 0, len);
				sendData(copy);
			}

			@Override
			public final void flush() {

				// Do nothing
			}

			@Override
			public final void close() {
				sendClose();
			}

		};

		// Bufferless/direct output
		if (packetSize < 2) {
			return out;
		}

		// Buffered output
		return new BufferedOutputStream(out, packetSize);
	}
489641
OutputStream writeChannel(int channel)
        throws IOException
    {
        while (os != null) {
            boolean canWrite = false;
            synchronized (WRITE_LOCK) {
                if (!isWriteLocked) {
                    isWriteLocked = true;
                    canWrite = true;
                }
                else {
                    try {
                        WRITE_LOCK.wait(5000);
                    } catch (Exception e) {
                    }
                }
            }

            if (canWrite) {
                os.write('C');
                os.write(channel >> 8);
                os.write(channel);

                return os;
            }
        }

        return null;
    }
540686
private static ZipOutputStream getZipOutputStream(OutputStream out, Charset charset) {
		charset = (null == charset) ? DEFAULT_CHARSET : charset;
		return new ZipOutputStream(out, charset);
	}