I am just trying to understand the wrapping of an array of bytes using ByteArrayInputStream class. Here is the code that I have doubt about it.
byte[] bytes = new byte[1024];
//write data into byte array...
InputStream input = new ByteArrayInputStream(bytes);
//read first byte
int data = input.read();
while(data != -1) {
//do something with data
//read next byte
data = input.read();
}
My question is it it possible to write this part
InputStream input = new ByteArrayInputStream(bytes);
like this
ByteArrayInputStream input = new ByteArrayInputStream(bytes);
And why the author of this code created the object with both the super and sub classes?
I really thank you for your help.