code: public static void copyBytes(final InputStream in, final OutputStream out, final int buffSize, final boolean close)
  			throws IOException {
  
  		@SuppressWarnings("resource")
  		final PrintStream ps = out instanceof PrintStream ? (PrintStream) out : null;
  		final byte[] buf = new byte[buffSize];
  		try {
  			int bytesRead = in.read(buf);
  			while (bytesRead >= 0) {
  				out.write(buf, 0, bytesRead);
  				if ((ps != null) && ps.checkError()) {
  					throw new IOException("Unable to write to output stream.");
  				}
  				bytesRead = in.read(buf);
  			}
  		} finally {
  			if (close) {
  				out.close();
  				in.close();
  			}
  		}
  	}
docs: Copies from one stream to another.
  
  @param in
  InputStream to read from
  @param out
  OutputStream to write to
  @param buffSize
  the size of the buffer
  @param close
  whether or not close the InputStream and OutputStream at the end. The streams are closed in the finally
  clause.
  @throws IOException
  thrown if an error occurred while writing to the output stream