Java Code Examples for org.tukaani.xz.XZ#CHECK_CRC32
The following examples show how to use
org.tukaani.xz.XZ#CHECK_CRC32 .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Check.java From packagedrone with Eclipse Public License 1.0 | 6 votes |
public static Check getInstance(int checkType) throws UnsupportedOptionsException { switch (checkType) { case XZ.CHECK_NONE: return new None(); case XZ.CHECK_CRC32: return new CRC32(); case XZ.CHECK_CRC64: return new CRC64(); case XZ.CHECK_SHA256: try { return new SHA256(); } catch (java.security.NoSuchAlgorithmException e) {} break; } throw new UnsupportedOptionsException( "Unsupported Check ID " + checkType); }
Example 2
Source File: Check.java From LocalGSMLocationProvider with Apache License 2.0 | 6 votes |
public static Check getInstance(int checkType) throws UnsupportedOptionsException { switch (checkType) { case XZ.CHECK_NONE: return new None(); case XZ.CHECK_CRC32: return new CRC32(); case XZ.CHECK_CRC64: return new CRC64(); case XZ.CHECK_SHA256: try { return new SHA256(); } catch (java.security.NoSuchAlgorithmException e) {} break; } throw new UnsupportedOptionsException( "Unsupported Check ID " + checkType); }
Example 3
Source File: XzStepTest.java From buck with Apache License 2.0 | 5 votes |
@Test public void testXzStep() throws IOException { Path sourceFile = TestDataHelper.getTestDataScenario(this, "compression_test").resolve("step.data"); File destinationFile = tmp.newFile("step.data.xz"); XzStep step = new XzStep( TestProjectFilesystems.createProjectFilesystem(tmp.getRoot().toPath()), sourceFile, destinationFile.toPath(), /* compressionLevel -- for faster testing */ 1, /* keep */ true, XZ.CHECK_CRC32); ExecutionContext context = TestExecutionContext.newInstance(); assertEquals(0, step.execute(context).getExitCode()); ByteSource original = PathByteSource.asByteSource(sourceFile); ByteSource decompressed = new ByteSource() { @Override public InputStream openStream() throws IOException { return new XZInputStream(new FileInputStream(destinationFile)); } }; assertTrue(Files.exists(sourceFile)); assertTrue( "Decompressed file must be identical to original.", original.contentEquals(decompressed)); }
Example 4
Source File: XzStepTest.java From buck with Apache License 2.0 | 5 votes |
@Test public void testXzStepDeletesOriginal() throws IOException { Path sourceFileOriginal = TestDataHelper.getTestDataScenario(this, "compression_test").resolve("step.data"); Path sourceFile = tmp.newFile("step.data").toPath(); Files.copy(sourceFileOriginal, sourceFile, StandardCopyOption.REPLACE_EXISTING); File destinationFile = tmp.newFile("step.data.xz"); XzStep step = new XzStep( TestProjectFilesystems.createProjectFilesystem(tmp.getRoot().toPath()), sourceFile, destinationFile.toPath(), /* compressionLevel -- for faster testing */ 1, /* keep */ false, XZ.CHECK_CRC32); ExecutionContext context = TestExecutionContext.newInstance(); assertEquals(0, step.execute(context).getExitCode()); ByteSource original = PathByteSource.asByteSource(sourceFileOriginal); ByteSource decompressed = new ByteSource() { @Override public InputStream openStream() throws IOException { return new XZInputStream(new FileInputStream(destinationFile)); } }; assertFalse(Files.exists(sourceFile)); assertTrue( "Decompressed file must be identical to original.", original.contentEquals(decompressed)); }
Example 5
Source File: XzStep.java From buck with Apache License 2.0 | 3 votes |
/** * Creates an XzStep to compress a file with XZ at a user supplied compression level . * * <p>The destination file will be {@code sourceFile} with the added {@code .xz} extension. * * <p>Decompression will require up to 64MiB of RAM. * * @param sourceFile file to compress * @param compressionLevel value from 0 to 9. Higher values result in better compression, but also * need more time to compress and will need more RAM to decompress. */ public XzStep(ProjectFilesystem filesystem, Path sourceFile, int compressionLevel) { this( filesystem, sourceFile, Paths.get(sourceFile + ".xz"), compressionLevel, /* keep */ false, XZ.CHECK_CRC32); }
Example 6
Source File: XzStep.java From buck with Apache License 2.0 | 2 votes |
/** * Creates an XzStep to compress a file with the given XZ compression level and output path. * * <p>Decompression will require up to 64MiB of RAM. * * @param sourceFile file to compress * @param outputPath the desired output path. * @param compressionLevel level of compression (from 0-9) */ public XzStep( ProjectFilesystem filesystem, Path sourceFile, Path outputPath, int compressionLevel) { this(filesystem, sourceFile, outputPath, compressionLevel, /* keep */ false, XZ.CHECK_CRC32); }