The list of methods to do OutputStream Write are organized into topic(s).
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);
...
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;
...
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(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) {
...