public static long copy(InputStream input, File file) throws IOException { try (FileOutputStream output = new FileOutputStream(file)) { return copy(input, output); } }
public static long copy(InputStream input, Writer writer) throws IOException { return copy(new InputStreamReader(input, StandardCharsets.UTF_8), writer); }
public static String toString(InputStream input) throws IOException { StringWriter writer = new StringWriter(); copy(input, writer); return writer.toString(); }
/** * Saves this file item to a given file on the server side. * * @param file * @throws IOException */ public void write(File file) throws IOException { try (InputStream inputStream = getInputStream()) { IoUtils.copy(inputStream, file); } }
private void send(InputStream input) throws IOException { try { // by calling httpServletResponse.getOutputStream() we are committing the response IoUtils.copy(input, httpServletResponse.getOutputStream()); if (chunked) { // flushing the buffer forces chunked-encoding httpServletResponse.flushBuffer(); } } finally { IoUtils.close(input); } }