Java Utililty Methods InputStream to OutputStream

List of utility methods to do InputStream to OutputStream

Description

The list of methods to do InputStream to OutputStream are organized into topic(s).

Method

longcopyStream(InputStream in, OutputStream out)
copy Stream
int BUFSIZE = 8192;
byte[] buf = new byte[BUFSIZE];
BufferedInputStream bin = new BufferedInputStream(in, BUFSIZE);
BufferedOutputStream bout = new BufferedOutputStream(out, BUFSIZE);
try {
    int c;
    long bytesWritten = 0l;
    while ((c = bin.read(buf)) != -1) {
...
intcopyStream(InputStream in, OutputStream out)
copy Stream
int length = 0;
byte[] buffer = new byte[1024];
for (int read = in.read(buffer); read != -1; read = in.read(buffer)) {
    out.write(buffer, 0, read);
    length += read;
out.flush();
out.close();
...
voidcopyStream(InputStream in, OutputStream out)
Copies streams.
in = new BufferedInputStream(in);
try {
    out = new BufferedOutputStream(out);
    try {
        while (true) {
            int data = in.read();
            if (data == -1)
                break;
...
longcopyStream(InputStream in, OutputStream out)
Copies data from one stream to another, until the input stream ends.
long total = 0;
int len;
byte[] buffer = new byte[DEFAULT_READ_BUFFER_SIZE];
while ((len = in.read(buffer)) >= 0) {
    out.write(buffer, 0, len);
    total += len;
return total;
...
voidcopyStream(InputStream in, OutputStream out)
Copy bytes from input to output stream, leaving out stream open
if (in == null) {
    throw new NullPointerException("Input stream is null");
if (out == null) {
    throw new NullPointerException("Output stream is null");
final byte[] buf = new byte[2048];
int len;
...
voidcopyStream(InputStream in, OutputStream out)
copy Stream
byte[] buffer = new byte[BUFSIZ];
for (;;) {
    int size = in.read(buffer);
    if (size <= 0)
        break;
    out.write(buffer, 0, size);
longcopyStream(InputStream in, OutputStream out)
Copies all the data from the specified input stream to the specified output stream.
byte[] buffer = new byte[5120];
long bytesCopied = 0;
int bytesInBuffer;
while ((bytesInBuffer = in.read(buffer)) != -1) {
    out.write(buffer, 0, bytesInBuffer);
    bytesCopied += bytesInBuffer;
return bytesCopied;
...
voidcopyStream(InputStream in, OutputStream out)
copy Stream
byte[] buf = new byte[4096];
int len;
while ((len = in.read(buf)) != -1) {
    out.write(buf, 0, len);
voidcopyStream(InputStream in, OutputStream out)
Copy stream 'in' to stream 'out'.
for (int c; (c = in.read()) != -1;)
    out.write(c);
voidcopyStream(InputStream in, OutputStream out)
Copy the content of one stream to another.
byte[] bytes = new byte[1024];
int len;
while ((len = in.read(bytes)) != -1)
    out.write(bytes, 0, len);