ByteArrayInputStream byteStream = new ByteArrayInputStream(data);
int offset =0;
int length = 1000;
byte[] sample = new byte[length];
while(byteStream.read(sample, offset, length)!= -1) {
System.out.println(sample);
offset = length +1;
length =length+1000;
}
i tried the same with ByteBuffer too. i got the same exception