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 in, File outputFile)
Copies the content from in into outputFile.
OutputStream os = new FileOutputStream(outputFile);
try {
    copyStreamUnsafelyUseWithCaution(in, os);
} finally {
    os.close();
voidcopyStream(InputStream in, FileOutputStream out, IProgressMonitor monitor, int length)
copy Stream
byte[] data = new byte[4096];
int count = in.read(data);
while (count != -1) {
    out.write(data, 0, count);
    if (length != -1) {
        monitor.worked(count);
    count = in.read(data);
...
voidcopyStream(InputStream in, OutputStream os)
Copies the content from in into os.
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
    os.write(buf, 0, len);
StringcopyStream(InputStream in, OutputStream os)
Simple copy a stream with a buffer of 1024 bytes into an outputstream.
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
    os.write(buf, 0, len);
os.flush();
if (os instanceof ByteArrayOutputStream) {
    return new String(((ByteArrayOutputStream) os).toByteArray(), "UTF-8");
...
longcopyStream(InputStream in, OutputStream out)
copy Stream
return copyStream(in, out, new byte[8192]);
voidcopyStream(InputStream in, OutputStream out)
copy Stream
while (true) {
    int read = in.read(BUFFER);
    if (read < 0)
        break;
    out.write(BUFFER, 0, read);
longcopyStream(InputStream in, OutputStream out)
copy Stream
return copyStream(in, out, 10240);
longcopyStream(InputStream in, OutputStream out)
Copies data from an InputStream to an OutputStream.
return copyStream(in, out, new byte[BUFFER_SIZE]);
voidcopyStream(InputStream in, OutputStream out)
Copy stream.
try {
    copyStreamNoClose(in, out);
} finally {
    safeClose(in);
    safeClose(out);
intcopyStream(InputStream in, OutputStream out)
DOCUMENT ME!
int result = 0;
byte[] buf = new byte[8 * 1024];
for (;;) {
    int numRead = in.read(buf);
    if (numRead == -1) {
        break;
    out.write(buf, 0, numRead);
...