code: public static void copy(
        InputStream inputStream, OutputStream outputStream, boolean closeInputStream)
        throws IOException {
      try {
        ByteStreams.copy(inputStream, outputStream);
      } finally {
        if (closeInputStream) {
          inputStream.close();
        }
      }
    }
docs: Writes the content provided by the given source input stream into the given destination output
  stream, optionally closing the input stream.
  
  <p>Sample use:
  
  <pre>
  static void copy(InputStream inputStream, File file) throws IOException {
  FileOutputStream out = new FileOutputStream(file);
  try {
  IOUtils.copy(inputStream, out, true);
  } finally {
  out.close();
  }
  }
  </pre>
  
  @param inputStream source input stream
  @param outputStream destination output stream
  @param closeInputStream whether the input stream should be closed at the end of this method