Here you can find the source of copyFile(InputStream in, OutputStream out, boolean close)
public static int copyFile(InputStream in, OutputStream out, boolean close) throws IOException
//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); } }