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

voidcopyStream(InputStream source, OutputStream dest)
Copy stream from source to destination
int bytes;
byte[] buffer;
int BUFFER_SIZE = 1024;
buffer = new byte[BUFFER_SIZE];
while ((bytes = source.read(buffer)) != -1) {
    if (bytes == 0) {
        bytes = source.read();
        if (bytes < 0)
...
voidcopyStream(InputStream source, OutputStream dest)
copy Stream
int bufferSize = 1024;
int bytes;
byte[] buffer;
buffer = new byte[bufferSize];
try {
    while ((bytes = source.read(buffer)) != -1) {
        if (bytes == 0) {
            bytes = source.read();
...
voidcopyStream(InputStream source, OutputStream dest)
Copy a stream from source to destination
int bytes;
byte[] buffer;
int BUFFER_SIZE = 1024;
buffer = new byte[BUFFER_SIZE];
while ((bytes = source.read(buffer)) > 0) {
    dest.write(buffer, 0, bytes);
voidcopyStream(InputStream source, OutputStream destination, byte[] buffer)
Reads all data (until EOF is reached) from the given source to the destination stream.
if (source == null) {
    throw new NullPointerException("Argument \"source\" must not be null.");
if (buffer == null) {
    buffer = new byte[8192];
if (destination != null) {
    int bytesRead;
...
voidcopyStream(InputStream sourceInputStream, OutputStream targetOutputStream)
copy Stream
int length = 1024;
byte[] bytes = new byte[length];
int c;
int total_bytes = 0;
try {
    while ((c = sourceInputStream.read(bytes)) != -1) {
        total_bytes += c;
        targetOutputStream.write(bytes, 0, c);
...
intcopyStream(InputStream sourceStream, OutputStream destinationStream)
Copies the data from an InputStream object to an OutputStream object.
int bytesRead = 0;
int totalBytes = 0;
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
while (bytesRead >= 0) {
    bytesRead = sourceStream.read(buffer, 0, buffer.length);
    if (bytesRead > 0) {
        destinationStream.write(buffer, 0, bytesRead);
    totalBytes += bytesRead;
destinationStream.flush();
destinationStream.close();
return totalBytes;
voidcopyStream(InputStream sourceStream, OutputStream destinationStream, boolean closeInput, boolean closeOutput)
Copy InputStream to OutputStream .
copyStream(sourceStream, destinationStream, DEFAULT_SIZE, closeInput, closeOutput);
voidcopyStream(InputStream src, OutputStream dest)
Insert the method's description here.
int c;
while ((c = src.read()) != -1) {
    dest.write(c);
booleancopyStream(InputStream src, OutputStream dest)
copy Stream
InputStream in = null;
OutputStream out = null;
byte[] buf = null;
int bufLen = 20000 * 1024;
try {
    in = new BufferedInputStream(src);
    out = new BufferedOutputStream(dest);
    buf = new byte[bufLen];
...
voidcopyStream(InputStream src, OutputStream dest, boolean closeStreams, String title)
copy Stream
boolean progress = title != null;
byte[] buffer = new byte[100 * 1024];
int length;
if (title != null)
    System.out.println(title);
try {
    while ((length = src.read(buffer)) >= 0) {
        dest.write(buffer, 0, length);
...