Here you can find the source of copyFile(OutputStream out, InputStream in)
static protected void copyFile(OutputStream out, InputStream in) throws IOException
//package com.java2s; /* Studio for kdb+ by Charles Skelton is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Germany License http://creativecommons.org/licenses/by-nc-sa/3.0 except for the netbeans components which retain their original copyright notice *///from w ww.j av a 2 s. c o m import java.io.*; public class Main { static protected void copyFile(OutputStream out, InputStream in) throws IOException { byte buffer[] = new byte[4096]; while (true) { int r = in.read(buffer); if (r <= 0) break; out.write(buffer, 0, r); } } static protected void copyFile(OutputStream out, String infile) throws IOException { FileInputStream fin = new FileInputStream(infile); copyFile(out, fin); fin.close(); } }