code: public static long copyAndCloseOutput(InputStream input, OutputStream output) throws IOException {
  		try (OutputStream outputStream = output) {
  			return copy(input, outputStream);
  		}
  	}
docs: Copy input to output and close the output stream before returning