List of utility methods to do OutputStream Write
void | copyBytes(InputStream in, OutputStream out, int buffSize, boolean close) Copies from one stream to another. try { copyBytes(in, out, buffSize); if (close) { out.close(); out = null; in.close(); in = null; } finally { if (close) { closeStream(out); closeStream(in); |
void | copyBytes(InputStream input, int size, OutputStream output) Copies a sequence of bytes from one stream to another. if (size == 0) { return; byte[] buffer = new byte[size]; readBytes(input, size, buffer); output.write(buffer); |
void | copyBytes(InputStream inputStream, OutputStream outputStream, int size) copy Bytes int bufferLength = BUFFER_SIZE; byte[] buf = new byte[bufferLength]; int bytesRead = 0; while (bytesRead < size) { int requestedBunchSize = Math.min(size - bytesRead, bufferLength); int read = inputStream.read(buf, 0, requestedBunchSize); bytesRead += read; outputStream.write(buf, 0, read); ... |
void | copyBytes(InputStream is, DataOutputStream[] os, long numBytes) copy Bytes byte buf[] = new byte[4096]; while (numBytes > 0) { int numBytesToRead = 4096; if (numBytes < 4096) numBytesToRead = (int) numBytes; int bytesRead = is.read(buf, 0, numBytesToRead); for (int i = 0; i < os.length; i++) { os[i].write(buf, 0, bytesRead); ... |
void | copyBytes(InputStream is, OutputStream bytes) copy Bytes int res = is.read(); while (res != -1) { bytes.write(res); res = is.read(); |
long | copyBytes(InputStream iStream, OutputStream oStream) Write all bytes available from Input- to OutputStream in pieces of DEFAULT_BUFFER_SIZE. long totalLength = 0; int length = -1; byte[] bytes = new byte[DEFAULT_BUFFER_SIZE]; while ((length = iStream.read(bytes)) != -1) { oStream.write(bytes, 0, length); totalLength += length; return totalLength; ... |
void | copyBytesAndClose(final InputStream is, final OutputStream os) Calls #copyBytes(java.io.InputStream,java.io.OutputStream) and safely closes both streams. try { copyBytes(is, os); } finally { try { os.close(); } finally { is.close(); |
File | copyBytesToFile(byte[] bytes, File outputFile) copy Bytes To File InputStream inputStream = new ByteArrayInputStream(bytes); 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(); ... |
void | copyBytesToStream(ByteArrayOutputStream from, OutputStream to) copy Bytes To Stream OutputStream out = new BufferedOutputStream(to); try { from.writeTo(out); } finally { out.flush(); |
void | copyBytesToStream(InputStream inputStream, OutputStream outputStream, int length) Copies given length amount of bytes from given inputStream to given outputStream. final int BUFFER_SIZE = 1024; byte[] buffer = new byte[BUFFER_SIZE]; int totalRead = 0; do { int readReqLen = (length == -1) ? BUFFER_SIZE : Math.min(BUFFER_SIZE, length - totalRead); int read = inputStream.read(buffer, 0, readReqLen); if (read == -1) { if (length != -1) { ... |