Java OutputStream Write copyFile(InputStream in, OutputStream out, boolean close)

Here you can find the source of copyFile(InputStream in, OutputStream out, boolean close)

Description

copy File

License

Open Source License

Declaration

public static int copyFile(InputStream in, OutputStream out,
            boolean close) 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 int copyFile(InputStream in, OutputStream out,
            boolean close) throws IOException {
        int size = 0;
        int b = in.read();

        while (b != -1) {
            size++;/*from   www . j  a  v  a 2s .c  o m*/
            out.write(b);
            b = in.read();
        }

        in.close();

        if (close) {
            out.close();
        }

        return (size);
    }
}

Related

  1. copyBytesToStream(ByteArrayOutputStream from, OutputStream to)
  2. copyBytesToStream(InputStream inputStream, OutputStream outputStream, int length)
  3. copyFile(File fromFile, File toFile)
  4. copyFile(final InputStream in, final OutputStream out, final int size)
  5. copyFile(InputStream in, OutputStream out)
  6. copyFile(InputStream inputStream, OutputStream outputStream)
  7. copyFile(OutputStream os, InputStream is)
  8. copyFile(String fileName, String newFileName)
  9. copyFilePermissions(File source, File target)