Open output stream

@return this request
@throws IOException
480180
private KieServerHttpRequest openOutput() throws IOException {
        if( output != null ) {
            return this;
        }
        getConnection().setDoOutput(true);
        final String charset = getHeaderParam(getConnection().getRequestProperty(CONTENT_TYPE), PARAM_CHARSET);
        output = new RequestOutputStream(getConnection().getOutputStream(), charset, bufferSize);
        return this;
    }
813439
private static InputStream openStream(String resource) throws IOException {
    HttpURLConnection
        connection =
        HttpURLConnection.class.cast(URI.create(resource).toURL().openConnection());
    connection.setConnectTimeout(1000 * 2);
    connection.setReadTimeout(1000 * 2);
    connection.setAllowUserInteraction(false);
    connection.setInstanceFollowRedirects(false);
    return connection.getInputStream();
  }
872466
public InputStream getInputStream() throws IOException {
        if (cachedContent == null) {
            cachedContent = mos.getData();
        }
        return new ByteArrayInputStream(cachedContent);
    }
963207
public File writeToStream(OutputStream out) throws IORuntimeException {
		FileInputStream in = null;
		try {
			in = new FileInputStream(file);
			IoUtil.copy(in, out);
		}catch (IOException e) {
			throw new IORuntimeException(e);
		} finally {
			IoUtil.close(in);
		}
		return this.file;
	}
1362394
@Override
    public InputStream openStream() {
        try {
            return new BufferedInputStream(new FileInputStream(file), 8192);
        } catch (FileNotFoundException e) {
            throw new RuntimeException("Could not open file " + file, e);
        }
    }
562431
protected synchronized InputStream getInputStream() throws IOException {
        if (isClosedOrPending()) {
            throw new IOException("Socket Closed");
        }
        if (shut_rd) {
            throw new IOException("Socket input is shutdown");
        }
        if (socketInputStream == null) {
            socketInputStream = new SocketInputStream(this);
        }
        return socketInputStream;
    }
534910
public void open() throws IOException {
        mConnection.connect();
        mContentType = mConnection.getContentType();
        mResponseCode = mConnection.getResponseCode();
        mContentEncoding = mConnection.getContentEncoding();
    }
1282889
public InputStream getInputStream() throws IOException {
    InputStream is = this.servletContext.getResourceAsStream(this.path);
    if (is == null) { throw new FileNotFoundException("Could not open " + getDescription()); }
    return is;
  }
1227555
private InputStream openFile() throws IOException {
    Path file = Paths.get(filePath);
    if (Files.exists(file)) {
      return Files.newInputStream(file);
    }
    InputStream input = getClass().getResourceAsStream(filePath);
    checkArgument(input != null, "Could not find file: " + filePath);
    return input;
  }
652722
public static function forOut(): OutputStream
    {
        if (null === self::$out) {
            self::$out = self::create('php://stdout');
        }

        return self::$out;
    }
286212
public OutputStream getRequestOutputStream()
        throws IOException, IllegalStateException {
        LOG.trace("enter HttpConnection.getRequestOutputStream()");
        assertOpen();
        OutputStream out = this.outputStream;
        if (Wire.CONTENT_WIRE.enabled()) {
            out = new WireLogOutputStream(out, Wire.CONTENT_WIRE);
        }
        return out;
    }
156833
public synchronized InputStream getInputStream() throws IOException {
        if (!connected) {
            connect();
        }

        // Nothing to return
        if (responseCode == HTTP_NOT_FOUND) {
            throw new FileNotFoundException(url.toString());
        }
        int length;

        if (inputStream == null) {
            return null;
        }

        // "De-chunk" the output stream
        else if ("chunked".equalsIgnoreCase(getHeaderField("Transfer-Encoding"))) {
            if (!(inputStream instanceof ChunkedInputStream)) {
                inputStream = new ChunkedInputStream(inputStream);
            }
        }

        // Make sure we don't wait forever, if the content-length is known
        else if ((length = getHeaderFieldInt("Content-Length", -1)) >= 0) {
            if (!(inputStream instanceof FixedLengthInputStream)) {
                inputStream = new FixedLengthInputStream(inputStream, length);
            }
        }
        return inputStream;
    }
640573
public ReadStreamOld openRead()
    throws IOException
  {
    closeWrite();
    
    TempReadStream read = new TempReadStream(_head);
    read.setFreeWhenDone(true);
    _head = null;
    _tail = null;
    
    return new ReadStreamOld(read);
  }
1316240
@Override
  public StreamImpl stream()
    throws IOException
  {
    if (_stream == null) {
      _stream = new JniStream(this);
    }

    _stream.init();

    return _stream;
  }
1360723
@Override
  public StreamImpl stream()
    throws IOException
  {
    if (_streamImpl == null) {
      _streamImpl = new SocketStream();
    }

    _streamImpl.init(_s);

    return _streamImpl;
  }
248766
public InputStream openStream()
    {
        if ( entity == null ) {
            return null;
        }

        try {
            return entity.getContent();
        } catch ( IOException ex ) {
            throw new CStorageException( "Can't open stream", ex );
        }
    }
503793
protected OkRequest<T> copy(final InputStream input, final OutputStream output) throws IOException {
        return new CloseOperation<OkRequest>(input, mIgnoreCloseExceptions) {

            @Override
            public OkRequest<T> call() throws IOException {
                boolean thrown = false;
                try {
                    final byte[] buffer = new byte[mBufferSize];
                    int read;
                    while ((read = input.read(buffer)) != -1) {
                        output.write(buffer, 0, read);
                    }
                    return OkRequest.this;
                } catch (IOException e) {
                    thrown = true;
                    throw e;
                } finally {
                    try {
                        done();
                    } catch (IOException e) {
                        if (!thrown) {
                            throw e;
                        }
                    }

                }

            }
        }.call();
    }