public static byte[] read(InputStream in) throws IOException{
byte[] arr=new
byte[1024];
ByteArrayOutputStream out=new
ByteArrayOutputStream();
int len=0;
while((len=in.read(arr))!=-1){
out.write(arr,
0, len);
}
out.close();
return out.toByteArray();
}