List of utility methods to do InputStream to OutputStream
void | copyStreamAndClose(InputStream is, OutputStream os) Copy input stream to output stream and close them both try { copyStream(is, os, DEFAULT_BUFFER_SIZE); is.close(); os.close(); } finally { safeClose(is); safeClose(os); |
void | copyStreamBounded(InputStream in, OutputStream out, long length) copy Stream Bounded final byte[] bytes = new byte[8192]; long totalCount = 0; while (totalCount < length) { int len = (int) Math.min(bytes.length, length - totalCount); int count = in.read(bytes, 0, len); if (count == -1) { throw new EOFException("Reached end of stream prematurely."); out.write(bytes, 0, count); totalCount += count; |
int | copyStreamContent(InputStream inputStream, OutputStream outputStream) copy Stream Content byte[] buffer = new byte[10240]; int total = 0; int count; while ((count = inputStream.read(buffer)) > 0) { outputStream.write(buffer, 0, count); total += count; return total; ... |
int | copyStreamContent(InputStream inputStream, OutputStream outputStream) Copy stream. final byte[] buffer = new byte[10 * 1024]; int count; int total = 0; while ((count = inputStream.read(buffer)) > 0) { outputStream.write(buffer, 0, count); total += count; return total; ... |
void | copyStreamFully(InputStream in, OutputStream out, int length) copy Stream Fully byte[] bytes = new byte[4096]; while (length > 0) { int newBytes = in.read(bytes, 0, Math.min(bytes.length, length)); if (newBytes < 0) { throw new EOFException(); out.write(bytes, 0, newBytes); length -= newBytes; ... |
void | copyStreamIoe(final InputStream is, final OutputStream os) Copies the data from the given input stream into the given output stream and doesn't wrap any IOException . int offset; final byte[] buffer = new byte[WUIC_BUFFER_LEN]; while ((offset = is.read(buffer)) != -1) { os.write(buffer, 0, offset); |
void | copyStreamNoClose(InputStream in, OutputStream out) copy Stream No Close final byte[] bytes = new byte[8192]; int cnt; while ((cnt = in.read(bytes)) != -1) { out.write(bytes, 0, cnt); out.flush(); |
void | copyStreamPortion(java.io.InputStream inputStream, java.io.OutputStream outputStream, int portionSize, int bufferSize) Read entire input stream portion and writes it data to output stream if (bufferSize > portionSize) { bufferSize = portionSize; byte[] writeBuffer = new byte[bufferSize]; int totalRead = 0; while (totalRead < portionSize) { int bytesToRead = bufferSize; if (bytesToRead > portionSize - totalRead) { ... |
void | copyStreams(final InputStream in, final OutputStream out) Copies all bytes from inputstream to outputstream. copyStreams(in, out, new byte[16384]); |
int | copyStreams(final InputStream input, final OutputStream output) This method copies the contents of an input stream to an output stream. int amtRead = 0; int totalLength = 0; byte[] segment = new byte[BUFFER_SEGMENT_LENGTH]; amtRead = input.read(segment, 0, segment.length); while (amtRead != -1) { totalLength += amtRead; output.write(segment, 0, amtRead); amtRead = input.read(segment, 0, segment.length); ... |