/** * @param stream Must be at start of file. Throws RuntimeException if !stream.markSupported(). * @return true if the given file looks like a valid BGZF file. */ public static boolean isValidFile(final InputStream stream) throws IOException { if (!stream.markSupported()) { throw new RuntimeException("Cannot test non-buffered stream"); } stream.mark(BlockCompressedStreamConstants.BLOCK_HEADER_LENGTH); final byte[] buffer = new byte[BlockCompressedStreamConstants.BLOCK_HEADER_LENGTH]; final int count = readBytes(stream, buffer, 0, BlockCompressedStreamConstants.BLOCK_HEADER_LENGTH); stream.reset(); return count == BlockCompressedStreamConstants.BLOCK_HEADER_LENGTH && isValidBlockHeader(buffer); }
/** * @param stream Must be at start of file. Throws RuntimeException if !stream.markSupported(). * @return true if the given file looks like a valid BGZF file. */ public static boolean isValidFile(final InputStream stream) throws IOException { if (!stream.markSupported()) { throw new RuntimeException("Cannot test non-buffered stream"); } stream.mark(BlockCompressedStreamConstants.BLOCK_HEADER_LENGTH); final byte[] buffer = new byte[BlockCompressedStreamConstants.BLOCK_HEADER_LENGTH]; final int count = readBytes(stream, buffer, 0, BlockCompressedStreamConstants.BLOCK_HEADER_LENGTH); stream.reset(); return count == BlockCompressedStreamConstants.BLOCK_HEADER_LENGTH && isValidBlockHeader(buffer); }
/** * @param stream Must be at start of file. Throws RuntimeException if !stream.markSupported(). * @return true if the given file looks like a valid BGZF file. */ public static boolean isValidFile(final InputStream stream) throws IOException { if (!stream.markSupported()) { throw new RuntimeException("Cannot test non-buffered stream"); } stream.mark(BlockCompressedStreamConstants.BLOCK_HEADER_LENGTH); final byte[] buffer = new byte[BlockCompressedStreamConstants.BLOCK_HEADER_LENGTH]; final int count = readBytes(stream, buffer, 0, BlockCompressedStreamConstants.BLOCK_HEADER_LENGTH); stream.reset(); return count == BlockCompressedStreamConstants.BLOCK_HEADER_LENGTH && isValidBlockHeader(buffer); }
/** * @param stream Must be at start of file. Throws RuntimeException if !stream.markSupported(). * @return true if the given file looks like a valid BGZF file. */ public static boolean isValidFile(final InputStream stream) throws IOException { if (!stream.markSupported()) { throw new RuntimeException("Cannot test non-buffered stream"); } stream.mark(BlockCompressedStreamConstants.BLOCK_HEADER_LENGTH); final byte[] buffer = new byte[BlockCompressedStreamConstants.BLOCK_HEADER_LENGTH]; final int count = readBytes(stream, buffer, 0, BlockCompressedStreamConstants.BLOCK_HEADER_LENGTH); stream.reset(); return count == BlockCompressedStreamConstants.BLOCK_HEADER_LENGTH && isValidBlockHeader(buffer); }