de.schlichtherle.truezip.zip.ZipOutputStream.write()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(97)

本文整理了Java中de.schlichtherle.truezip.zip.ZipOutputStream.write()方法的一些代码示例,展示了ZipOutputStream.write()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipOutputStream.write()方法的具体详情如下:
包路径:de.schlichtherle.truezip.zip.ZipOutputStream
类名称:ZipOutputStream
方法名:write

ZipOutputStream.write介绍

暂无

代码示例

代码示例来源:origin: uk.gov.nationalarchives/droid-results

private long writeFile(BufferedInputStream in, ZipOutputStream out, //ZipArchiveOutputStream out,
      ProgressObserver observer, long bytesSoFar, long totalSize) 
    throws IOException {
    long totalBytesWritten = bytesSoFar;
    int bytesIn = 0;
    byte[] buffer = new byte[BUFFER_SIZE];
    while ((bytesIn = in.read(buffer)) != -1) {
      totalBytesWritten += bytesIn;
      int progressSoFar = (int) ((UNITY_PERCENT * totalBytesWritten) / totalSize);
      observer.onProgress(progressSoFar);
      out.write(buffer, 0, bytesIn);
    }
    return totalBytesWritten;
  }
}

代码示例来源:origin: digital-preservation/droid

private long writeFile(final InputStream in, final ZipOutputStream out, //ZipArchiveOutputStream out,
      final ProgressObserver observer, final long bytesSoFar, final long totalSize)
    throws IOException {
    long totalBytesWritten = bytesSoFar;
    int bytesIn = 0;
    byte[] buffer = new byte[BUFFER_SIZE];
    while ((bytesIn = in.read(buffer)) != -1) {
      totalBytesWritten += bytesIn;
      int progressSoFar = (int) ((UNITY_PERCENT * totalBytesWritten) / totalSize);
      observer.onProgress(progressSoFar);
      out.write(buffer, 0, bytesIn);
    }
    return totalBytesWritten;
  }
}

代码示例来源:origin: de.schlichtherle.truezip/truezip-driver-zip

@Test
public final void testGoodGetCheckedInputStream() throws IOException {
  // Create test ZIP file.
  final String name = "entry";
  final ZipOutputStream zipOut
      = newZipOutputStream(new FileOutputStream(file));
  zipOut.putNextEntry(newEntry(name));
  zipOut.write(data);
  zipOut.close();
  final ZipFile zipIn = newZipFile(file);
  // Open checked input stream and join immediately.
  InputStream in = zipIn.getCheckedInputStream(name);
  in.close();
  // Open checked input stream and read fully, using multiple methods.
  in = zipIn.getCheckedInputStream(name);
  final int n = data.length / 4;
  in.skip(n);
  in.read(new byte[n]);
  in.read(new byte[n], 0, n);
  while (in.read() != -1) { // read until EOF
  }
  in.close();
  zipIn.close();
}

代码示例来源:origin: de.schlichtherle.truezip/truezip-driver-zip

private void append(
      final int off,
      final int len,
      final byte[] data)
  throws IOException {
    final ZipOutputStream out;
    if (file.exists()) {
      final ZipFile in = newZipFile(file);
      in.close();
      out = newZipOutputStream(new FileOutputStream(file, true), in);
    } else {
      out = newZipOutputStream(new FileOutputStream(file));
    }
    try {
      for (int i = 0; i < len; i++) {
        final String name = off + i + ".txt";
        out.putNextEntry(newEntry(name));
        out.write(data);
      }
    } finally {
      out.close();
    }
  }
}

代码示例来源:origin: de.schlichtherle.truezip/truezip-driver-zip

@Test
public final void testWriteAndReadSingleBytes() throws IOException {
  final ZipOutputStream zipOut
      = newZipOutputStream(new FileOutputStream(file));
  zipOut.putNextEntry(newEntry("file"));
  for (int i = 0; i < data.length; i++)
    zipOut.write(data[i]);
  zipOut.close();
  final ZipFile zipIn = newZipFile(file);
  InputStream in = zipIn.getInputStream("file");
  for (int i = 0, c; (c = in.read()) != -1; i++)
    assertEquals(data[i] & 0xFF, c);
  in.close();
  zipIn.close();
}

代码示例来源:origin: de.schlichtherle.truezip/truezip-driver-zip

try {
  zipOut.putNextEntry(newEntry(name));
  zipOut.write(data);
} finally {
  zipOut.close();

代码示例来源:origin: de.schlichtherle.truezip/truezip-driver-zip

String name = i + ".txt";
zout.putNextEntry(newEntry(name));
zout.write(data);
assertTrue(set.add(name));

代码示例来源:origin: de.schlichtherle.truezip/truezip-driver-zip

zos.write(data);
assertTrue(set.add(name));

相关文章