Java tutorial
//package com.java2s; import java.io.*; public class Main { public static byte[] readInput(InputStream in) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); int len = 0; byte[] buffer = new byte[1024]; while ((len = in.read(buffer)) > 0) { out.write(buffer, 0, len); } out.close(); in.close(); return out.toByteArray(); } }