try (final ZipArchiveInputStream zipIn = new ZipArchiveInputStream(new BufferedInputStream(in))) { ArchiveEntry zipEntry; while ((zipEntry = zipIn.getNextEntry()) != null) { if (zipEntry.isDirectory() || !fileMatches(zipEntry)) { continue;
public ZipPartStore(InputStream is) throws Docx4JException { initMaxBytes(); partByteArrays = new HashMap<String, ByteArray>(); try { ZipArchiveInputStream zis = new ZipArchiveInputStream(is); ArchiveEntry entry = null; while ((entry = zis.getNextEntry()) != null) { // How to read the data descriptor for length? ie before reading? byte[] bytes = getBytesFromInputStream( zis ); //log.debug("Extracting " + entry.getName()); policePartSize(null, bytes.length, entry.getName()); partByteArrays.put(entry.getName(), new ByteArray(bytes) ); } zis.close(); } catch (PartTooLargeException e) { throw e; } catch (Exception e) { throw new Docx4JException("Error processing zip file (is it a zip file?)", e); } }
@PostMapping("/import/{version:.+}") public ModelAndView importData(@PathVariable String version, MultipartFile file){ final String fileName = file.getOriginalFilename(); LOGGER.info("Upload file : {}", fileName); try (InputStream in = file.getInputStream()) { if (fileName.endsWith(PROPERTIES)) { saveGroup(version, fileName, in); } else if (fileName.endsWith(ZIP)) { try (ZipArchiveInputStream input = new ZipArchiveInputStream(in)) { ArchiveEntry nextEntry = null; while ((nextEntry = input.getNextEntry()) != null) { String entryName = nextEntry.getName(); saveGroup(version, entryName, input); } } } } catch (IOException e) { LOGGER.error(e.getMessage(), e); } return new ModelAndView("redirect:/version/" + version); }
public LineIterator getEntries() throws IOException { if(name.endsWith(".zip")){ ZipArchiveInputStream zipIn = new ZipArchiveInputStream(is); zipIn.getNextEntry(); return IOUtils.lineIterator(zipIn, "UTF-8"); } else { return IOUtils.lineIterator(is, "UTF-8"); } }
ZipArchiveInputStream zipArchiveInputStream = new ZipArchiveInputStream(is)) { ArchiveEntry archiveEntry; while ((archiveEntry = zipArchiveInputStream.getNextEntry()) != null) {
zis = new ZipArchiveInputStream(fis, "Cp1252", true); // this supports non-USACII names ArchiveEntry entry; while ((entry = zis.getNextEntry()) != null) { File file = new File(outputFolder, entry.getName()); if (entry.isDirectory()) {
try (final ZipArchiveInputStream zipIn = new ZipArchiveInputStream(new BufferedInputStream(in))) { ArchiveEntry zipEntry; while ((zipEntry = zipIn.getNextEntry()) != null) { if (zipEntry.isDirectory() || !fileMatches(zipEntry)) { continue;
ArchiveEntry archiveEntry = archiveInputStream.getNextEntry(); while (archiveEntry != null) { File outputFile = null; archiveEntry = archiveInputStream.getNextEntry();
public ZipPartStore(InputStream is) throws Docx4JException { initMaxBytes(); partByteArrays = new HashMap<String, ByteArray>(); try { ZipArchiveInputStream zis = new ZipArchiveInputStream(is); ArchiveEntry entry = null; while ((entry = zis.getNextEntry()) != null) { // How to read the data descriptor for length? ie before reading? byte[] bytes = getBytesFromInputStream( zis ); //log.debug("Extracting " + entry.getName()); policePartSize(null, bytes.length, entry.getName()); partByteArrays.put(entry.getName(), new ByteArray(bytes) ); } zis.close(); } catch (PartTooLargeException e) { throw e; } catch (Exception e) { throw new Docx4JException("Error processing zip file (is it a zip file?)", e); } }
ArchiveEntry archiveEntry = archiveInputStream.getNextEntry(); while (archiveEntry != null) { File outputFile = null; archiveEntry = archiveInputStream.getNextEntry();
ZipArchiveOutputStream zos = new ZipArchiveOutputStream(fos); ZipArchiveEntry ze; while ((ze = (ZipArchiveEntry) zis.getNextEntry()) !=null) {