code: public static long copy(InputStream pIn, OutputStream pOut, boolean pClose, byte[] pBuffer) throws IOException {
  		OutputStream out = pOut;
  		InputStream in = pIn;
  		try {
  			long total = 0;
  			for (;;) {
  				int res = in.read(pBuffer);
  				if (res == -1) {
  					break;
  				}
  				if (res > 0) {
  					total += res;
  					if (out != null) {
  						out.write(pBuffer, 0, res);
  					}
  				}
  			}
  			if (out != null) {
  				if (pClose) {
  					out.close();
  				} else {
  					out.flush();
  				}
  				out = null;
  			}
  			in.close();
  			in = null;
  			return total;
  		} finally {
  			if (in != null) {
  				try {
  					in.close();
  				} catch (Throwable t) {
  					/* Ignore me */
  				}
  			}
  			if (pClose && out != null) {
  				try {
  					out.close();
  				} catch (Throwable t) {
  					/* ignore me */
  				}
  			}
  		}
  	}
docs: Copies the contents of the given {@link InputStream} to the given {@link OutputStream}.
  
  @param pIn The input stream, which is being read. It is guaranteed, that {@link InputStream#close()} is called on
  the stream.
  @param pOut The output stream, to which data should be written. May be null, in which case the input streams
  contents are simply discarded.
  @param pClose True guarantees, that {@link OutputStream#close()} is called on the stream. False indicates, that
  only {@link OutputStream#flush()} should be called finally.
  @param pBuffer Temporary buffer, which is to be used for copying data.
  
  @return Number of bytes, which have been copied.
  @throws IOException An I/O error occurred.