while (skipped < value) { final long rem = value - skipped; final int x = read(skipBuf, 0, (int) (skipBuf.length > rem ? rem : skipBuf.length)); if (x == -1) { return skipped;
@Test public void test1() throws IOException { ZipArchiveInputStream zis = new ZipArchiveInputStream(BadZipEntryFlagTest.class.getResourceAsStream("/bad.zip")); for (ZipArchiveEntry e = zis.getNextZipEntry(); e != null; e = zis.getNextZipEntry()) { e.getGeneralPurposeBit().useEncryption(false); if (!e.isDirectory()) { zis.read(); System.out.println(e.getName()); } } }
try(ZipArchiveInputStream zipArchiveInputStream = new ZipArchiveInputStream(fileInputStream)) { ZipArchiveEntry zipEntry; while ((zipEntry = zipArchiveInputStream.getNextZipEntry()) != null){ String fileName = zipEntry.getName(); final File file = new File(fileName); FileUtil.createMissingParentDirectories(file); try(FileOutputStream fileOutputStream = new FileOutputStream(file.getAbsolutePath())) {(file.read.buffer) try(BufferedOutputStream bos = new BufferedOutputStream(fileOutputStream, 1024)) { int n = 0; byte[] content = new byte[1024]; while ((n = zipArchiveInputStream.read(content)) != -1) { fileOutputStream.write(content, 0, n); } bos.flush(); } } } } }
while (skipped < value) { final long rem = value - skipped; final int x = read(skipBuf, 0, (int) (skipBuf.length > rem ? rem : skipBuf.length)); if (x == -1) { return skipped;
throw new IOException("Cannot create directory '" + parentDir + "'"); outUnzipped = new BufferedOutputStream(new FileOutputStream(unzippedFile), BUFFER_SIZE); while ((byteCount = zipStream.read(buffer, 0, BUFFER_SIZE)) != -1) outUnzipped.write(buffer, 0, byteCount); outUnzipped.close();
fos = new FileOutputStream(file); int read; while ((read = zis.read(buffer,0,buffer.length)) != -1) fos.write(buffer,0,read); fos.close();
zipStream.read(data);
offset += zin.read(buffer, offset, size - offset);