First, it looks like inputSTreamToByteArray()
is reading the entire stream until end of file, not just the first 8192 bytes. You probably want to read the first 8192 bytes separately first.
Second, do you want to re-read those bytes again? If not, I'm not sure if you need to mark/reset. (Especially since you still have the byte array )
The code below reads the first 8192 bytes first, then decides what to do:
byte[] header = new byte[8192];
//reads entire array or until EOF whichever is first
bis.read(header);
if(isFileType(header)) {
byte[] finalBytes = inputStreamToByteArray(bis);
methodForFinalBytes(finalBytes);
} else {
// Do other stuff;
}