mirror of
https://github.com/xerial/snappy-java.git
synced 2025-05-05 07:20:15 +02:00
Add test for isValidCompressedBuffer. Add a comment on the usage of SnappyOutputStream
This commit is contained in:
parent
7795673e0c
commit
ae6a126d1c
@ -34,8 +34,14 @@ import java.io.OutputStream;
|
||||
* The input data is blocked into 32kb size (in default), and each block is
|
||||
* compressed and then passed to the given {@link OutputStream}.
|
||||
*
|
||||
* The output data format is a sequence of (compressed chunk size, compressed
|
||||
* data chunk binary...) pair.
|
||||
* The output data format is a sequence of (compressed data size, compressed
|
||||
* data...) pair.
|
||||
*
|
||||
* Note that the compressed data created by {@link SnappyOutputStream} cannot be
|
||||
* uncompressed by {@link Snappy#uncompress(byte[])} since the output formats of
|
||||
* {@link Snappy#compress(byte[])} and {@link SnappyOutputStream} are different.
|
||||
* Use {@link SnappyInputStream} for uncompress the data generated by
|
||||
* {@link SnappyOutputStream}.
|
||||
*
|
||||
* @author leo
|
||||
*
|
||||
|
@ -283,4 +283,14 @@ public class SnappyTest
|
||||
assertEquals(s, uncompressedString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isValidCompressedData() throws Exception {
|
||||
|
||||
byte[] b = new byte[] { (byte) 91, (byte) 34, (byte) 80, (byte) 73, (byte) 34, (byte) 93 };
|
||||
if (Snappy.isValidCompressedBuffer(b, 0, b.length)) {
|
||||
byte[] uncompressed = Snappy.uncompress(b);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user