use of java.util.zip.ZipInputStream in project bazel by bazelbuild.
the class ZipCombinerTest method testMergeStrategyWithSlowCopy.
@Test
public void testMergeStrategyWithSlowCopy() throws IOException {
MockZipEntryFilter mockFilter = new MockZipEntryFilter();
mockFilter.behavior.put("hello.txt", new SlowConcatenateStrategy());
ByteArrayOutputStream out = new ByteArrayOutputStream();
try (ZipCombiner zipCombiner = new ZipCombiner(mockFilter, out)) {
zipCombiner.addZip(sampleZip());
zipCombiner.addZip(sampleZipWithTwoEntries());
}
assertEquals(Arrays.asList("hello.txt", "hello2.txt"), mockFilter.calls);
ZipInputStream zipInput = new ZipInputStream(new ByteArrayInputStream(out.toByteArray()));
assertEntry(zipInput, "hello2.txt", "Hello World 2!");
assertEntry(zipInput, "hello.txt", "Hello World!Hello World!");
assertNull(zipInput.getNextEntry());
}
use of java.util.zip.ZipInputStream in project bazel by bazelbuild.
the class ZipCombinerTest method testCopyTwoUncompressedEntries.
@Test
public void testCopyTwoUncompressedEntries() throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try (ZipCombiner zipCombiner = new ZipCombiner(out)) {
zipCombiner.addZip(sampleZipWithTwoUncompressedEntries());
}
ZipInputStream zipInput = new ZipInputStream(new ByteArrayInputStream(out.toByteArray()));
assertEntry(zipInput, "hello.txt", "Hello World!");
assertEntry(zipInput, "hello2.txt", "Hello World 2!");
assertNull(zipInput.getNextEntry());
}
use of java.util.zip.ZipInputStream in project bazel by bazelbuild.
the class ZipCombinerTest method testCombine.
@Test
public void testCombine() throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try (ZipCombiner zipCombiner = new ZipCombiner(out)) {
zipCombiner.addZip(sampleZip());
zipCombiner.addZip(sampleZip2());
}
ZipInputStream zipInput = new ZipInputStream(new ByteArrayInputStream(out.toByteArray()));
assertEntry(zipInput, "hello.txt", "Hello World!");
assertEntry(zipInput, "hello2.txt", "Hello World 2!");
assertNull(zipInput.getNextEntry());
}
use of java.util.zip.ZipInputStream in project bazel by bazelbuild.
the class ZipCombinerTest method testCopyDateHandling.
@Test
public void testCopyDateHandling() throws IOException {
final Date date = new GregorianCalendar(2009, 8, 2, 0, 0, 0).getTime();
ZipEntryFilter mockFilter = new ZipEntryFilter() {
@Override
public void accept(String filename, StrategyCallback callback) throws IOException {
assertEquals("hello.txt", filename);
callback.copy(date);
}
};
ByteArrayOutputStream out = new ByteArrayOutputStream();
try (ZipCombiner zipCombiner = new ZipCombiner(mockFilter, out)) {
zipCombiner.addZip(sampleZip());
}
ZipInputStream zipInput = new ZipInputStream(new ByteArrayInputStream(out.toByteArray()));
assertEntry(zipInput, "hello.txt", date, "Hello World!");
assertNull(zipInput.getNextEntry());
}
use of java.util.zip.ZipInputStream in project jadx by skylot.
the class ClsSet method load.
public void load(File input) throws IOException, DecodeException {
String name = input.getName();
InputStream inputStream = new FileInputStream(input);
try {
if (name.endsWith(CLST_EXTENSION)) {
load(inputStream);
} else if (name.endsWith(".jar")) {
ZipInputStream in = new ZipInputStream(inputStream);
try {
ZipEntry entry = in.getNextEntry();
while (entry != null) {
if (entry.getName().endsWith(CLST_EXTENSION)) {
load(in);
}
entry = in.getNextEntry();
}
} finally {
close(in);
}
} else {
throw new JadxRuntimeException("Unknown file format: " + name);
}
} finally {
close(inputStream);
}
}
Aggregations