Java tutorial
//package com.java2s; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; public class Main { private static int COPYSTREAM_BUFFER_SIZE = 2 * 1024; public static boolean copyStream(InputStream src, OutputStream dest) { byte[] buffer = new byte[COPYSTREAM_BUFFER_SIZE]; try { int size; while ((size = src.read(buffer)) != -1) { dest.write(buffer, 0, size); } } catch (IOException e) { return false; } return true; } }