打开文件为OutputStream.

@see {@link Files#newOutputStream}
191610
public static OutputStream asOututStream(File file) throws IOException {
		Validate.notNull(file, "file is null");
		return asOututStream(file.toPath());
	}
907251
public OutputStream getOutput(GridFile file) throws IOException {
      checkIsNotDirectory(file);
      createIfNeeded(file);
      return new GridOutputStream(file, false, data);
   }
271640
private void setupOutputStream() {
    synchronized (failureLogFile) {
      // Setup is done by some thread
      if (hasSetupOutputStream) {
        return;
      }

      try {
        boolean append = false;
        if (fs.exists(failureLogFile)) {
          log.info("Failure log file %s already exists, appending to it", failureLogFile);
          append = true;
        }
        OutputStream outputStream = append ? fs.append(failureLogFile) : fs.create(failureLogFile);
        output = this.closer.register(new PrintStream(outputStream, false, Charsets.UTF_8.toString()));
      } catch (IOException e) {
        throw new RuntimeException(e);
      } finally {
        hasSetupOutputStream = true;
      }
    }
  }
1129101
public final ServletOutputStream getOutputStream() throws IOException {
        if (out == null) {
            OutputStream out = createOutputStream();
            this.out = out instanceof ServletOutputStream ? out : new OutputStreamAdapter(out);
        }
        else if (out instanceof PrintWriter) {
            throw new IllegalStateException("getWriter() already called.");
        }

        return (ServletOutputStream) out;
    }
863702
public void writeTo(OutputStream out) throws IOException {
        if (!(out instanceof DataOutput)) {
            out = new DataOutputStream(out);
        }

        writeTo((DataOutput)out);

        out.flush();
    }
632091
private static PrintStream openStream(File out) throws IOException {
    OutputStream os = new FileOutputStream(out);
    os = out.getName().endsWith(GZIP_POSTFIX) ? new GZIPOutputStream(os) : os;
    return new PrintStream(os);
  }
1313059
@Override
    public ServletOutputStream getOutputStream() throws IOException {

        if(_out == null ){
            //create the outputstream 
            _out = new SRTUpgradeOutputStream31();       
            _outbb = new UpgradeOutputByteBufferUtil(this);
            _out.init(_outbb,_req);
        }
        return _out;
    }
860091
public static OutputStream getFileOutputStream(String filename) throws IOException {
    OutputStream out = new FileOutputStream(filename);
    if (filename.endsWith(".gz")) {
      out = new GZIPOutputStream(out);
    } else if (filename.endsWith(".bz2")) {
      //out = new CBZip2OutputStream(out);
      out = getBZip2PipedOutputStream(filename);
    }
    return out;
  }
1273879
@Override
    public OutputStream getOutputStream() throws IOException {
        if (Files.isDirectory(this.path)) {
            throw new FileNotFoundException(getPath() + " (is a directory)");
        }
        return Files.newOutputStream(this.path);
    }
274750
private static function initializeOutputStreams()
    {
        if (self::$out === null) {
            if (!defined('STDOUT')) {
                self::$out = new OutputStream(fopen('php://stdout', 'w'));
            } else {
                self::$out = new OutputStream(STDOUT);
            }
        }
        if (self::$err === null) {
            if (!defined('STDERR')) {
                self::$err = new OutputStream(fopen('php://stderr', 'w'));
            } else {
                self::$err = new OutputStream(STDERR);
            }
        }
    }
692371
protected OutputStream createOutputStream (File target)
        throws IOException
    {
        JarOutputStream jout = new JarOutputStream(new FileOutputStream(target));
        jout.setLevel(Deflater.BEST_COMPRESSION);
        return jout;
    }
172883
private void copy(final InputStream inputStream, final FileOutputStream outputStream) throws IOException {
        final byte[] buffer = new byte[1024*4];
        int n;
        try {
            while (-1 != (n = inputStream.read(buffer))) {
                outputStream.write(buffer, 0, n);
            }
        } finally {
            inputStream.close();
            outputStream.close();
        }
    }
245205
public File output() throws IOException {
        File o = new File(output);
        if (!o.exists() && !o.mkdirs()) {
            throw new IOException("Unable to create output folder '" + output + "'");
        }
        return o;
    }
819180
protected OutputStream createStagingFileOutputStream()
      throws IOException {
    OutputStream out = this.fs
        .create(this.stagingFile, this.filePermission, true, this.bufferSize, this.replicationFactor, this.blockSize,
            null);

    // encoders need to be attached to the stream in reverse order since we should write to the
    // innermost encoder first
    for (StreamCodec encoder : Lists.reverse(getEncoders())) {
      out = encoder.encodeOutputStream(out);
    }

    return this.closer.register(out);
  }
1255364
@Override
	public FSDataOutputStream create(Path f, WriteMode overwriteMode) throws IOException {
		return createOutputStream(() -> originalFs.create(f, overwriteMode));
	}
251859
protected InputStream createInputStream() throws IOException {
      if (asFile().isPresent()) {
         return new FileInputStream(asFile().orElse(null));
      }
      return null;
   }
89188
public void write(OutputStream out)
         throws IOException
    {
        Writer writer = new OutputStreamWriter(out);
        write(writer);
        writer.flush();
    }