Ejemplo n.º 1
0
 @Test
 public void decompress() throws FileNotFoundException, IOException {
   SnappyCompression compress = new SnappyCompression();
   compress.decompressAndClose(
       new FileInputStream("/tmp/test1.snp"),
       new FileOutputStream("/tmp/compress-test-out-2.txt"));
   String md1 = SystemUtils.md5(new File("/tmp/compress-test.txt"));
   String md2 = SystemUtils.md5(new File("/tmp/compress-test-out-2.txt"));
   assertEquals(md1, md2);
 }
Ejemplo n.º 2
0
  @Test
  public void snappyDecompress() throws IOException {
    // decompress normally.
    SnappyInputStream is =
        new SnappyInputStream(new BufferedInputStream(new FileInputStream("/tmp/test0.snp")));
    byte d[] = new byte[1024];
    FileOutputStream fos = new FileOutputStream("/tmp/compress-test-out-1.txt");
    BufferedOutputStream dest1 = new BufferedOutputStream(fos, 1024);
    int c;
    while ((c = is.read(d, 0, 1024)) != -1) {
      dest1.write(d, 0, c);
    }
    IOUtils.closeQuietly(dest1);
    IOUtils.closeQuietly(is);

    String md1 = SystemUtils.md5(new File("/tmp/compress-test-out-1.txt"));
    String md2 = SystemUtils.md5(new File("/tmp/compress-test.txt"));
    assertEquals(md1, md2);
  }
Ejemplo n.º 3
0
 @Test
 public void unzip() throws IOException {
   BufferedOutputStream dest1 = null;
   BufferedInputStream is = null;
   ZipFile zipfile = new ZipFile("/tmp/compressed.zip");
   Enumeration e = zipfile.entries();
   while (e.hasMoreElements()) {
     ZipEntry entry = (ZipEntry) e.nextElement();
     is = new BufferedInputStream(zipfile.getInputStream(entry));
     int c;
     byte d[] = new byte[2048];
     FileOutputStream fos = new FileOutputStream("/tmp/compress-test-out-0.txt");
     dest1 = new BufferedOutputStream(fos, 2048);
     while ((c = is.read(d, 0, 2048)) != -1) {
       dest1.write(d, 0, c);
     }
     IOUtils.closeQuietly(dest1);
     IOUtils.closeQuietly(is);
   }
   String md1 = SystemUtils.md5(new File("/tmp/compress-test.txt"));
   String md2 = SystemUtils.md5(new File("/tmp/compress-test-out-0.txt"));
   assertEquals(md1, md2);
 }