Android Utililty Methods InputStream Copy

List of utility methods to do InputStream Copy

Description

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

Method

voidCopyStream(InputStream is, OutputStream os)
Copy stream.
final int buffer_size = 1024;
try {
    byte[] bytes = new byte[buffer_size];
    for (;;) {
        int count = is.read(bytes, 0, buffer_size);
        if (count == -1)
            break;
        os.write(bytes, 0, count);
...
voidcopy(InputStream in, BufferedOutputStream out)
Copy.
int byte_;
while ((byte_ = in.read()) != -1)
    out.write(byte_);
voidcopy(InputStream in, OutputStream out)
Copy the content of the input stream into the output stream, using a temporary byte array buffer whose size is defined by #IO_BUFFER_SIZE .
byte[] b = new byte[IO_BUFFER_SIZE];
int read;
while ((read = in.read(b)) != -1) {
    out.write(b, 0, read);
voidcopy(InputStream in, OutputStream out)
Copy the content of the input stream into the output stream, using a temporary byte array buffer whose size is defined by #IO_BUFFER_SIZE .
byte[] b = new byte[IO_BUFFER_SIZE];
int read;
while ((read = in.read(b)) != -1) {
    out.write(b, 0, read);
longcopy(InputStream in, OutputStream out)
Copies the content of the InputStream to the OutputStream.
long filesize = 0;
try {
    byte[] buffer = new byte[BUFF_SIZE];
    int bytesRead = in.read(buffer);
    while (bytesRead != -1) {
        filesize += bytesRead;
        out.write(buffer, 0, bytesRead);
        bytesRead = in.read(buffer);
...
intcopy(InputStream input, OutputStream output)
Copy bytes from an InputStream to an OutputStream.
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
int count = 0;
int n = 0;
while (-1 != (n = input.read(buffer))) {
    output.write(buffer, 0, n);
    count += n;
return count;
...
voidcopy(InputStream input, Writer output)
Copy and convert bytes from an InputStream to chars on a Writer.
InputStreamReader in = new InputStreamReader(input);
copy(in, output);
voidcopy(InputStream input, Writer output, String encoding)
Copy and convert bytes from an InputStream to chars on a Writer, using the specified encoding.
InputStreamReader in = new InputStreamReader(input, encoding);
copy(in, output);
voidcopy(InputStream inputStream, OutputStream outputStream)
Copies from the InputStream into the OutputStream .
byte[] buffer = new byte[8 * 1024];
int count = 0;
do {
    outputStream.write(buffer, 0, count);
    count = inputStream.read(buffer, 0, buffer.length);
} while (count != -1);
voidcopy(InputStream pSourceStream, OutputStream pTargetStream)
destination is not closed on exit of method !
copy(pSourceStream, pTargetStream, true);