Android InputStream Read writeToStream(InputStream in, OutputStream out, boolean closeOnExit)

Here you can find the source of writeToStream(InputStream in, OutputStream out, boolean closeOnExit)

Description

write To Stream

Declaration

public static void writeToStream(InputStream in, OutputStream out,
            boolean closeOnExit) throws IOException 

Method Source Code

//package com.java2s;

import java.io.IOException;
import java.io.InputStream;

import java.io.OutputStream;

public class Main {
    public static void writeToStream(InputStream in, OutputStream out,
            boolean closeOnExit) throws IOException {
        byte[] bytes = new byte[2048];
        for (int c = in.read(bytes); c != -1; c = in.read(bytes)) {
            out.write(bytes, 0, c);//from   w  w  w .j  a  v  a2s  .  c om
        }
        if (closeOnExit) {
            in.close();
            out.close();
        }
    }
}

Related

  1. ReadString(FileInputStream stream)
  2. readContents(InputStream input, String encoding)
  3. readFile(InputStream input)
  4. readFully(InputStream in)
  5. readInputStreamToString(InputStream input, String enCoding)
  6. readStream(InputStream in)
  7. readStream(InputStream in)
  8. readStream(InputStream in)
  9. readToFile(InputStream in, File localFile)