Java tutorial
//package com.java2s; import java.io.InputStream; import java.io.OutputStream; public class Main { public static OutputStream loadInputStreamToOutputStream(InputStream input, OutputStream output) { int BUFFER_SIZE = 1024 * 4; byte[] buffer = new byte[BUFFER_SIZE]; int n = 0; try { while (-1 != (n = input.read(buffer))) { output.write(buffer, 0, n); } } catch (Exception e) { } return output; } }