Here you can find the source of copyBytes(InputStream is, OutputStream bytes)
private static void copyBytes(InputStream is, OutputStream bytes) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { private static void copyBytes(InputStream is, OutputStream bytes) throws IOException { int res = is.read(); while (res != -1) { bytes.write(res);//w w w. j a va2 s. c o m res = is.read(); } } }