Java InputStream to OutputStream copyStream(InputStream in, OutputStream out)

Here you can find the source of copyStream(InputStream in, OutputStream out)

Description

copy Stream

License

Open Source License

Declaration

public static void copyStream(InputStream in, OutputStream out) throws IOException 

Method Source Code


//package com.java2s;
// it under the terms of the GNU General Public License as published by

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;

public class Main {
    public static void copyStream(InputStream in, OutputStream out) throws IOException {
        byte[] buf = new byte[4096];
        int len;//from w ww  .  j a v a  2s  .c o  m

        while ((len = in.read(buf)) != -1) {
            out.write(buf, 0, len);
        }
    }

    public static void copyStream(BufferedReader in, OutputStreamWriter out) throws IOException {
        char[] buf = new char[4096];
        int len;

        while ((len = in.read(buf)) != -1) {
            out.write(buf, 0, len);
        }
    }
}

Related

  1. copyStream(InputStream in, OutputStream out)
  2. copyStream(InputStream in, OutputStream out)
  3. copyStream(InputStream in, OutputStream out)
  4. copyStream(InputStream in, OutputStream out)
  5. copyStream(InputStream in, OutputStream out)
  6. copyStream(InputStream in, OutputStream out)
  7. copyStream(InputStream in, OutputStream out)
  8. copyStream(InputStream in, OutputStream out)
  9. copyStream(InputStream in, OutputStream out)