/** try to read a BCFVersion from an uncompressed BufferedInputStream. * The buffer must be large enough to contain {@link #SIZEOF_BCF_HEADER} * * @param bufferedinput the uncompressed input stream * @return the BCFVersion if it can be decoded, or null if not found. * @throws IOException */ public static BCFVersion tryReadBCFVersion(final BufferedInputStream uncompressedBufferedInput) throws IOException { uncompressedBufferedInput.mark(SIZEOF_BCF_HEADER); final BCFVersion bcfVersion = BCFVersion.readBCFVersion(uncompressedBufferedInput); uncompressedBufferedInput.reset(); return bcfVersion; }
/** try to read a BCFVersion from an uncompressed BufferedInputStream. * The buffer must be large enough to contain {@link #SIZEOF_BCF_HEADER} * * @param bufferedinput the uncompressed input stream * @return the BCFVersion if it can be decoded, or null if not found. * @throws IOException */ public static BCFVersion tryReadBCFVersion(final BufferedInputStream uncompressedBufferedInput) throws IOException { uncompressedBufferedInput.mark(SIZEOF_BCF_HEADER); final BCFVersion bcfVersion = BCFVersion.readBCFVersion(uncompressedBufferedInput); uncompressedBufferedInput.reset(); return bcfVersion; }
@Override public boolean canDecode( final String path ) { FileInputStream fis = null; try { fis = new FileInputStream(path); final BCFVersion version = BCFVersion.readBCFVersion(fis); return version != null && version.getMajorVersion() == ALLOWED_MAJOR_VERSION; } catch ( FileNotFoundException e ) { return false; } catch ( IOException e ) { return false; } finally { try { if ( fis != null ) fis.close(); } catch ( IOException e ) { // do nothing } } }
@Override public boolean canDecode( final String path ) { try (InputStream fis = Files.newInputStream(IOUtil.getPath(path)) ){ final BCFVersion version = BCFVersion.readBCFVersion(fis); return version != null && version.getMajorVersion() == ALLOWED_MAJOR_VERSION; } catch ( final IOException e ) { return false; } }
@Override public boolean canDecode( final String path ) { try (InputStream fis = Files.newInputStream(IOUtil.getPath(path)) ){ final BCFVersion version = BCFVersion.readBCFVersion(fis); return version != null && version.getMajorVersion() == ALLOWED_MAJOR_VERSION; } catch ( final IOException e ) { return false; } }
try { bcfVersion = BCFVersion.readBCFVersion(inputStream); if ( bcfVersion == null ) error("Input stream does not contain a BCF encoded file; BCF magic header info not found");
try { bcfVersion = BCFVersion.readBCFVersion(inputStream); if ( bcfVersion == null ) error("Input stream does not contain a BCF encoded file; BCF magic header info not found");
try { bcfVersion = BCFVersion.readBCFVersion(inputStream); if ( bcfVersion == null ) error("Input stream does not contain a BCF encoded file; BCF magic header info not found");