List of utility methods to do InputStream to OutputStream
int | copyStream(final InputStream inputStream, final OutputStream outputStream) copy Stream int result = 0; final byte[] buf = new byte[BUFFER]; for (;;) { final int numRead = inputStream.read(buf); if (numRead == -1) { break; outputStream.write(buf, 0, numRead); ... |
void | copyStream(final InputStream is, final OutputStream os) copy Stream byte[] buf = new byte[16 * 1024]; while (true) { int len = is.read(buf); if (len <= 0) { break; os.write(buf, 0, len); |
boolean | copyStream(final InputStream is, final OutputStream os) Copy a stream to another location try { final byte[] buf = new byte[1024]; int len; while ((len = is.read(buf)) > 0) { os.write(buf, 0, len); is.close(); os.close(); ... |
long | copyStream(final InputStream is, final OutputStream out, final Long amount, final int bufferSize) Copies the length of bytes from the inputstream to the outputStream. long bytesProcessed = 0; byte[] buf = new byte[bufferSize]; int bytesReadOut = 0; while (((amount == null) || (bytesProcessed < amount.longValue())) && (bytesReadOut > -1)) { int bytesToRead = bufferSize; if (amount != null) { long bytesLeft = amount.longValue() - bytesProcessed; if ((bytesLeft < bytesToRead)) { ... |
long | copyStream(final InputStream source, final OutputStream target) Copies the supplied InputStream to the provided OutputStream . long size = 0L; try { final byte[] buffer = new byte[BUFFER_SIZE]; int length; while ((length = source.read(buffer, 0, buffer.length)) >= 0) { size += length; target.write(buffer, 0, length); return size; } finally { close(source); close(target); |
void | copyStream(final InputStream src, OutputStream dest) Writes the content of an input stream to an output stream byte[] buffer = new byte[1024]; int read = 0; while ((read = src.read(buffer)) > -1) { dest.write(buffer, 0, read); dest.flush(); |
void | copyStream(final OutputStream to, final InputStream from) Copy one stream to another until the input stream has no more data. final byte[] buf = new byte[BUF_SIZE]; int len = from.read(buf); while (len > 0) { to.write(buf, 0, len); len = from.read(buf); |
void | copyStream(InputStream fis, OutputStream fos) copy Stream try { byte[] buffer = new byte[0xFFFF]; for (int len; (len = fis.read(buffer)) != -1;) fos.write(buffer, 0, len); } catch (IOException e) { System.err.println(e); } finally { if (fis != null) { ... |
long | copyStream(InputStream from, OutputStream to) copy Stream long total = 0; byte[] buf = new byte[2048]; while (true) { int r = from.read(buf); if (r == -1) { break; to.write(buf, 0, r); ... |
int | copyStream(InputStream in, boolean closeIn, OutputStream out, boolean closeOut) copy Stream try { int written = 0; byte[] buffer = new byte[16 * 1024]; int len; while ((len = in.read(buffer)) != -1) { out.write(buffer, 0, len); written += len; return written; } finally { try { if (closeIn) { in.close(); } finally { if (closeOut) { out.close(); |