List of utility methods to do InputStream to OutputStream
void | copyStreamSafely(InputStream in, ByteArrayOutputStream os) Copies the content from in into os. try { copyStreamUnsafelyUseWithCaution(in, os); } finally { in.close(); |
File | copyStreamToFile(final InputStream stream, final File output) Helper function for writing a text stream to a file. final BufferedReader r = new BufferedReader(new InputStreamReader(stream)); String l = null; final PrintWriter writer = new PrintWriter(new FileWriter(output)); while ((l = r.readLine()) != null) { writer.println(l); writer.close(); r.close(); ... |
File | copyStreamToFile(InputStream input, String outputPath) copy Stream To File File file = new File(outputPath); try { DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file))); InputStream is = input; byte[] buf = new byte[1024]; int len; while ((len = is.read(buf)) > 0) { out.write(buf, 0, len); ... |
void | CopyStreamToFile(InputStream inputStream, File outputFile) Copies a InputStream into a file. InputStreamReader in = new InputStreamReader(inputStream); FileWriter out = new FileWriter(outputFile); int c; while ((c = in.read()) != -1) { out.write(c); in.close(); out.close(); ... |
File | copyStreamToFile(InputStream inputStream, File outputFile) copy Stream To File OutputStream outputStream = new FileOutputStream(outputFile); byte[] buf = new byte[BUFFER_SIZE]; int len; while ((len = inputStream.read(buf)) > 0) { outputStream.write(buf, 0, len); outputStream.close(); inputStream.close(); ... |
void | copyStreamToFile(InputStream is, File outputFile) Copy contents of a stream to a target file. OutputStream os = new BufferedOutputStream(new FileOutputStream(outputFile)); copyStreamToStream(is, os); os.close(); |
void | copyStreamToFile(InputStream stream, String outputFilePath) Uses the default charset BufferedInputStream is = new BufferedInputStream(stream); OutputStream os = null; try { os = new FileOutputStream(new File(outputFilePath)); byte[] b = new byte[1024]; int read; while ((read = is.read(b)) != -1) { os.write(b, 0, read); ... |
File | copyStreamToFileBinary(final InputStream stream, final File output) Helper function for writing a binary stream to a file. final FileOutputStream out = new FileOutputStream(output); final byte buf[] = new byte[1024]; int len = 0; while ((len = stream.read(buf)) > 0) out.write(buf, 0, len); out.close(); stream.close(); return output; ... |
void | copyStreamToStream(final InputStream input, final OutputStream output) Copy any input stream to output stream. InputStream is = null; OutputStream os = null; int ch; try { if (input instanceof BufferedInputStream) { is = input; } else { is = new BufferedInputStream(input); ... |
void | copyStreamToStream(InputStream in, OutputStream out) Copy the contents of an InputStream, up to EOF, to the given OutputStream. byte[] buf = new byte[BUFFER_SIZE]; int len; try { while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } finally { in.close(); ... |