List of usage examples for org.apache.commons.compress.compressors.snappy FramedSnappyCompressorInputStream matches
public static boolean matches(final byte[] signature, final int length)
From source file:org.apache.tika.parser.pkg.TikaCompressorStreamFactory.java
/** * Try to detect the type of compressor stream. * * @param in input stream//from w w w.java 2 s . c om * @return type of compressor stream detected * @throws CompressorException if no compressor stream type was detected * or if something else went wrong * @throws IllegalArgumentException if stream is null or does not support mark * * @since 1.14 */ public static String detect(final InputStream in) throws CompressorException { if (in == null) { throw new IllegalArgumentException("Stream must not be null."); } if (!in.markSupported()) { throw new IllegalArgumentException("Mark is not supported."); } final byte[] signature = new byte[12]; in.mark(signature.length); int signatureLength = -1; try { signatureLength = IOUtils.readFully(in, signature); in.reset(); } catch (IOException e) { throw new CompressorException("IOException while reading signature.", e); } if (BZip2CompressorInputStream.matches(signature, signatureLength)) { return BZIP2; } if (GzipCompressorInputStream.matches(signature, signatureLength)) { return GZIP; } if (Pack200CompressorInputStream.matches(signature, signatureLength)) { return PACK200; } if (FramedSnappyCompressorInputStream.matches(signature, signatureLength)) { return SNAPPY_FRAMED; } if (ZCompressorInputStream.matches(signature, signatureLength)) { return Z; } if (DeflateCompressorInputStream.matches(signature, signatureLength)) { return DEFLATE; } if (XZUtils.matches(signature, signatureLength)) { return XZ; } if (LZMAUtils.matches(signature, signatureLength)) { return LZMA; } /* if (FramedLZ4CompressorInputStream.matches(signature, signatureLength)) { return LZ4_FRAMED; }*/ throw new CompressorException("No Compressor found for the stream signature."); }