Here you can find the source of inStream2byte(InputStream inStream)
public static byte[] inStream2byte(InputStream inStream) throws Exception
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.InputStream; public class Main { public static byte[] inStream2byte(InputStream inStream) throws Exception { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int len = 0; while ((len = inStream.read(buffer)) != -1) { outStream.write(buffer, 0, len); }/*from w w w .j av a 2s . c o m*/ inStream.close(); return outStream.toByteArray(); } }