code: public long guessNextBGZFBlockStart(long beg, long end)
  		throws IOException
  	{
  		// Buffer what we need to go through. Since the max size of a BGZF block
  		// is 0xffff (64K), and we might be just one byte off from the start of
  		// the previous one, we need 0xfffe bytes for the start, and then 0xffff
  		// for the block we're looking for.
  
  		byte[] arr = new byte[2*0xffff - 1];
  
  		this.seekableInFile.seek(beg);
  		int totalRead = 0;
  		for (int left = Math.min((int)(end - beg), arr.length); left > 0;) {
  			final int r = inFile.read(arr, totalRead, left);
  			if (r < 0)
  				break;
  			totalRead += r;
  			left -= r;
  		}
  		arr = Arrays.copyOf(arr, totalRead);
  
  		this.in = new ByteArraySeekableStream(arr);
  
  		final BlockCompressedInputStream bgzf =
  			new BlockCompressedInputStream(this.in);
  		bgzf.setCheckCrcs(true);
  
  		final int firstBGZFEnd = Math.min((int)(end - beg), 0xffff);
  
  		for (int pos = 0;;) {
  			pos = guessNextBGZFPos(pos, firstBGZFEnd);
  			if (pos < 0)
  				return end;
  
  			try {
  				// Seek in order to trigger decompression of the block and a CRC
  				// check.
  				bgzf.seek((long)pos << 16);
  
  			// This has to catch Throwable, because it's possible to get an
  			// OutOfMemoryError due to an overly large size.
  			} catch (Throwable e) {
  				// Guessed BGZF position incorrectly: try the next guess.
  				++pos;
  				continue;
  			}
  			return beg + pos;
  		}
  	}
docs: / Looks in the range [beg,end). Returns end if no BAM record was found.