Copies the content from in into os.
<p>
This method closes the input stream.
<i>os</i> does not need to be closed.
</p>

@param in an input stream (not null)
@param os an output stream (not null)
@throws IOException if an error occurred
438992
public static void copyStreamSafely( InputStream in, ByteArrayOutputStream os ) throws IOException {

		try {
			copyStreamUnsafelyUseWithCaution( in, os );

		} finally {
			in.close();
		}
	}
903990
public static void copy(byte[] in, File out) throws IOException {
        assert in != null : "No input byte array specified";
        assert out != null : "No output File specified";
        ByteArrayInputStream inStream = new ByteArrayInputStream(in);
        OutputStream outStream = new BufferedOutputStream(new FileOutputStream(out));
        copy(inStream, outStream);
    }
269933
public void writeToStream(OutputStreamWithBuffer os)
    throws IOException
  {
    StreamImpl is = openReadImpl();

    try {
      byte []buffer = os.buffer();
      int offset = os.offset();
      int length = buffer.length;

      while (! os.isClosed()) {
        int sublen = length - offset;

        if (sublen <= 0) {
          buffer = os.nextBuffer(offset);
          offset = os.offset();
          sublen = length - offset;
        }

        sublen = is.read(buffer, offset, sublen);

        if (sublen <= 0) {
          os.offset(offset);
          return;
        }

        offset += sublen;
      }
    } finally {
      is.close();
    }
  }
686021
public void copyFrom(InputStream in) throws IOException, InterruptedException {
        try (OutputStream os = write()) {
            org.apache.commons.io.IOUtils.copy(in, os);
        }
    }
823018
public static void close (InputStream in)
    {
        if (in != null) {
            try {
                in.close();
            } catch (IOException ioe) {
                log.warning("Error closing input stream", "stream", in, "cause", ioe);
            }
        }
    }
648714
private static void inflater(InputStream in, OutputStream out) {
		final InflaterOutputStream ios = (out instanceof InflaterOutputStream) ? (InflaterOutputStream) out : new InflaterOutputStream(out, new Inflater(true));
		IoUtil.copy(in, ios);
		try {
			ios.finish();
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
	}
221326
public static void copy(String in, Charset charset, OutputStream out) throws IOException {
		Writer writer = new OutputStreamWriter(out, charset);
		writer.write(in);
		writer.flush();
	}
12973
public void close() throws IOException {
        if(inp != null)
            inp.close();
        if(out != null)
            out.close();
    }
726263
public void writeToStream(OutputStream os)
    throws IOException
  {
    StreamImpl is = openReadImpl();
    TempBuffer tempBuffer = TempBuffer.create();
    try {
      byte []buffer = tempBuffer.buffer();
      int length = buffer.length;
      int len;

      while ((len = is.read(buffer, 0, length)) > 0) {
        os.write(buffer, 0, len);
      }
    } finally {
      TempBuffer.free(tempBuffer);
      tempBuffer = null;

      is.close();
    }
  }
1367636
public static void copy(Reader in, Writer out) throws IOException {
    char[] buf = new char[1024];
    while (true) {
      int count = in.read(buf);
      if (count < 0) {
        break;
      }
      out.write(buf, 0, count);
    }
    out.flush();
  }
1225785
public void writeTo(OutputStream os, long startByte, long count) 
        throws IOException
    {
        if (count<0)
            count=_buf.length-startByte;
        if (_buf!=null)
            os.write(_buf, (int) startByte, (int) count);
    }
558308
public static void copy(InputStream in, Writer writer) throws IOException {
    copy(getInputStreamReader(in), writer);
    writer.flush();
  }
157452
public static void copyStream(InputStream is, OutputStream os, int size) 
	throws IOException {
		byte[] buffer = new byte[size];
		for (int r = -1; (r = is.read(buffer, 0, size)) != -1;) {
			os.write(buffer, 0, r);
		}
	}
1299639
public static int copy(File in, File out) throws IOException {
		Assert.notNull(in, "No input File specified");
		Assert.notNull(out, "No output File specified");
		return copy(new BufferedInputStream(new FileInputStream(in)),
			new BufferedOutputStream(new FileOutputStream(out)));
	}
693254
public static int copy(Resource in, File out) throws IOException {
        assert in != null : "No input File specified";
        assert out != null : "No output File specified";
        return copy(new BufferedInputStream(in.getInputStream()),
            new BufferedOutputStream(Files.newOutputStream(out.toPath())));
    }
1225357
private void copy(InputStream is, OutputStream os) throws IOException {
		byte[] buffer = new byte[bufferSize];
		int nRead;
		while((nRead = is.read(buffer)) != -1) {
			os.write(buffer, 0, nRead);
		}
		os.flush();
	}
1273505
public static void copy(final InputStream in, final OutputStream out)
			throws IOException {
		copy(in, out, DEFAULT_BUFFER_SIZE);
	}