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

booleancopyStream(InputStream src, OutputStream osstream)
copy Stream
BufferedOutputStream bos = null;
BufferedInputStream bis = null;
boolean copied = true;
try {
    bos = new BufferedOutputStream(osstream);
    bis = new BufferedInputStream(src);
    byte[] buffer = new byte[MAX_BUFFER_SIZE];
    int count;
...
voidCopyStream(InputStream sSource, OutputStream sTarget)
Copy Stream
assert (sSource != null && (sTarget != null));
if (sSource == null)
    throw new IllegalArgumentException("sSource");
if (sTarget == null)
    throw new IllegalArgumentException("sTarget");
final int nBufSize = 4096;
byte[] pbBuf = new byte[nBufSize];
int read;
...
booleancopyStream(int bufferSize, InputStream in, OutputStream out, boolean canStop)
Copy an input stream to an output stream.
byte[] buffer = new byte[bufferSize];
int n;
long copied = 0L;
while (-1 != (n = in.read(buffer))) {
    out.write(buffer, 0, n);
    copied += n;
    if (canStop && Thread.interrupted())
        return false;
...
java.io.OutputStreamcopyStream(java.io.InputStream in, java.io.OutputStream out)
Copies all data from 'in' stream to 'out' stream.
byte buffer[] = new byte[8192];
int length;
try {
    while ((length = in.read(buffer)) != -1)
        out.write(buffer, 0, length);
} finally {
    in.close();
return out;
voidcopyStream(java.io.InputStream inputStream, java.io.OutputStream outputStream)
copy Stream
copyStream(inputStream, outputStream, DEFAULT_BUFFER_SIZE);
intcopyStream(java.io.InputStream src, java.io.OutputStream dest)
Copy an input stream to an output stream.
return copyStream(src, dest, Long.MAX_VALUE);
voidcopyStream(OutputStream out, InputStream in, int bufsz)
copy Stream
byte[] buf = new byte[bufsz];
int n = 0;
while ((n = in.read(buf)) > 0) {
    out.write(buf, 0, n);
voidcopyStream(OutputStream outStream, InputStream inStream)
Copies specified input stream to specified output stream.
try {
    byte[] bytes = new byte[1024];
    int count = inStream.read(bytes);
    while (count > 0) {
        outStream.write(bytes, 0, count);
        count = inStream.read(bytes);
} catch (IOException e) {
...
voidcopyStream(Reader input, Writer output)
Coping data(character type) from input reader to output writer.
copyStream(input, output, 4096);
voidcopyStreamAndClose(InputStream is, OutputStream os)
Copy input stream to output stream and close them both
try {
    copyStream(is, os);
} finally {
    if (is != null) {
        try {
            is.close();
        } catch (IOException ignored) {
    if (os != null)
        os.close();