Java tutorial
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { /** * Read input from input stream and write it to output stream * until there is no more input from input stream. * * @param is input stream the input stream to read from. * @param os output stream the output stream to write to. * @param buf the byte array to use as a buffer */ public static void flow(InputStream is, OutputStream os, byte[] buf) throws IOException { int numRead; while ((numRead = is.read(buf)) >= 0) { os.write(buf, 0, numRead); } } }