Here you can find the source of inputStreamToByte(InputStream is)
public static byte[] inputStreamToByte(InputStream is)
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.InputStream; public class Main { public static byte[] inputStreamToByte(InputStream is) { try {/* w ww . ja va2 s . c o m*/ ByteArrayOutputStream bytestream = new ByteArrayOutputStream(); int ch; while ((ch = is.read()) != -1) { bytestream.write(ch); } byte imgdata[] = bytestream.toByteArray(); bytestream.close(); return imgdata; } catch (Exception e) { e.printStackTrace(); } return null; } }