Copies this stream to the output stream.

@param os destination stream.
4639
public void writeToStream(OutputStream os) throws IOException
  {
    if (_readLength <= _readOffset) {
      readBuffer();
    }

    while (_readOffset < _readLength) {
      os.write(_readBuffer, _readOffset, _readLength - _readOffset);

      readBuffer();
    }
  }
1060943
private void copyToStream(String txt, OutputStream stream) throws IOException {
        if (txt != null) {
            stream.write(txt.getBytes());
        }
    }
725114
public static void copyStream( File inputFile, OutputStream os ) throws IOException {
		InputStream is = new FileInputStream( inputFile );
		try {
			copyStreamUnsafelyUseWithCaution( is, os );
		} finally {
			is.close();
		}
	}
686021
public void copyFrom(InputStream in) throws IOException, InterruptedException {
        try (OutputStream os = write()) {
            org.apache.commons.io.IOUtils.copy(in, os);
        }
    }
1297531
public void write(OutputStream os)
	{
		List<String> ids = new ArrayList<String>(score.keySet());
		final Map<String, Integer> score = this.score;
		Collections.sort(ids, new Comparator<String>()
		{
			@Override
			public int compare(String o1, String o2)
			{
				return score.get(o2).compareTo(score.get(o1));
			}
		});

		try
		{
			BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os));

			boolean notFirst = false;

			for (String id : ids)
			{
				if (notFirst) writer.write("\n");
				else notFirst = true;

				writer.write(id + DELIM + score.get(id) + DELIM + convertContext(context.get(id)));
			}

			writer.close();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
703076
static public void copyStream(InputStream is, OutputStream os) throws IOException {
		copyStream(is, os, DEFAULT_TRANSFER_BUFFER_SIZE);
	}
691644
private static void copy(InputStream source, OutputStream sink) throws IOException {
        byte[] buf = new byte[8192];
        int n;
        while ((n = source.read(buf)) > 0) {
            sink.write(buf, 0, n);
        }
    }
844862
public boolean readToOutputStream(OutputStream os)
        throws IOException
    {
        InputStream is = readInputStream();

        if (is == null)
            return false;

        if (_buffer == null)
            _buffer = new byte[256];

        try {
            int len;

            while ((len = is.read(_buffer, 0, _buffer.length)) > 0) {
                os.write(_buffer, 0, len);
            }

            return true;
        } finally {
            is.close();
        }
    }
196654
public static int write(InputStream is, OutputStream os, boolean closeSink) {
        return copy(is, os, closeSink);
    }
595380
public void setProcessInputStream(OutputStream os) {
    if (input != null) {
      if (input == System.in) {
        inputThread = createSystemInPump(input, os);
      }
      else {
        inputThread = createPump(input, os, true, true);
      }
    }
    else {
      try {
        os.close();
      }
      catch (IOException e) {
        log.info("Got exception while closing output stream", e);
      }
    }
  }
1038509
public void writeToOutputStream(OutputStream os) throws IOException {
		if(sb == null) {
			throw new IllegalStateException("No interal StringBuffer");
		}
		byte[] b;
		try {
			b = getBytes();
		} catch (UnsupportedEncodingException e) {
			throw new RuntimeException(e);
		}
		os.write(b);
	}
192434
public static void copyStream(InputStream copyFrom, OutputStream copyTo)
			throws IOException {
		copyStream(copyFrom, copyTo, null);
	}
224602
public static void copyStream(InputStream from, OutputStream to) throws IOException {
        byte buffer[] = new byte[2048];
        int bytesRead;
        while ((bytesRead = from.read(buffer)) != -1) {
            to.write(buffer, 0, bytesRead);
        }
        from.close();
    }
312156
private boolean copy(InputStream source, String destination) {
        boolean success = true;

        try
        {
            Files.copy(source, Paths.get(destination), StandardCopyOption.REPLACE_EXISTING);
        } catch (IOException ex)
        {
            LOG.fatal("Cannot write file " + destination, ex);
            success = false;
        }

        return success;
    }
382960
public static void copy(InputStream source, File destination) throws IOException {
        OutputStream output = null;

        try {
            output = new FileOutputStream(destination);
            copy(source, output);
        } finally {
            closeQuietly(output);
        }
    }
218901
static public void copyStream(InputStream is, OutputStream os, int transferBufferSize) throws IOException {
		if( transferBufferSize < 1 ) {
			throw new IOException("Transfer buffer size can not be smaller than 1");
		}

		byte[] buffer = new byte[transferBufferSize];

		int bytesRead = is.read(buffer);
		while( bytesRead >= 0 ) {
			os.write(buffer, 0, bytesRead);

			bytesRead = is.read(buffer);
		}
	}
992915
public void serialize(Map<String, T> map, OutputStream os) throws IOException {
        JsonGenerator jsonGenerator = LoganSquare.JSON_FACTORY.createGenerator(os);
        serialize(map, jsonGenerator);
        jsonGenerator.close();
    }