private void addZipEntryAndWrite(ZipOutputStream zipStream, String onePinFileName, byte[] onePinDataCsv) throws IOException { ZipEntry zipEntry = new ZipEntry(onePinFileName); try { zipStream.putNextEntry(zipEntry); zipStream.write(onePinDataCsv); zipStream.closeEntry(); } catch (ZipException zipException) { String message = zipException.getMessage(); if (message != null && message.contains("duplicate")) { log.warn("Duplicate zip entry {}. Wrong report configuration.", onePinFileName); } else { log.error("Error compressing report file.", message); throw zipException; } } catch (IOException e) { log.error("Error compressing report file.", e.getMessage()); throw e; } }
/** * @return the jar */ private JarFile getJar(boolean create) { assert Thread.holdsLock(closeSync); if (jar == null && create) { try { if (root.canRead()) { jar = new JarFile(root); LOGGER.log(Level.FINE, "opened: {0} {1}", new Object[]{root.getAbsolutePath(), System.currentTimeMillis()}); //NOI18N return jar; } } catch (ZipException ex) { dumpFDs(); LOGGER.log(Level.INFO, ex.getMessage(), ex); } catch (IOException ex) { LOGGER.log(Level.INFO, ex.getMessage(), ex); } LOGGER.log(Level.WARNING, "cannot open {0}", root.getAbsolutePath()); // NOI18N } return jar; }
/** * Sets the central directory part of extra fields. * * @param b boolean */ public void setCentralDirectoryExtra(final byte[] b) { try { final ZipExtraField[] central = ExtraFieldUtils.parse(b, false, ExtraFieldUtils.UnparseableExtraField.READ); mergeExtraFields(central, false); } catch (final ZipException e) { throw new RuntimeException(e.getMessage(), e); //NOSONAR } }
/** * Sets the central directory part of extra fields. */ public void setCentralDirectoryExtra(byte[] b) { try { ZipExtraField[] central = ExtraFieldUtils.parse(b, false, ExtraFieldUtils.UnparseableExtraField.READ); mergeExtraFields(central, false); } catch (ZipException e) { throw new RuntimeException(e.getMessage(), e); } }
/** * Sets the central directory part of extra fields. * @param b an array of bytes to be parsed into extra fields */ public void setCentralDirectoryExtra(final byte[] b) { try { final ZipExtraField[] central = ExtraFieldUtils.parse(b, false, ExtraFieldUtils.UnparseableExtraField.READ); mergeExtraFields(central, false); } catch (final ZipException e) { throw new RuntimeException(e.getMessage(), e); //NOSONAR } }
ZipArchiveEntry getNextEntry() throws IOException { if (!(in instanceof ZipArchiveInputStream)) { throw new IllegalStateException("getNextEntry() is only allowed for stream based zip processing."); } try { entry = ((ZipArchiveInputStream) in).getNextZipEntry(); return entry; } catch (ZipException ze) { if (ze.getMessage().startsWith("Unexpected record signature")) { throw new NotOfficeXmlFileException( "No valid entries or contents found, this is not a valid OOXML (Office Open XML) file", ze); } throw ze; } }
if (ex.getMessage().contains("duplicate")) {
new GZIPInputStream(new ByteArrayInputStream(data), 2048))); } catch (ZipException e) { if (e.getMessage().equals("Not in GZIP format")) { GlowServer.logger.info("Incorrect region version, switching to zlib..."); file.seek((sectorNumber * SECTOR_BYTES) + Integer.BYTES);
/** * Parses the given bytes as extra field data and consumes any * unparseable data as an {@link UnparseableExtraFieldData} * instance. * @param extra an array of bytes to be parsed into extra fields * @throws RuntimeException if the bytes cannot be parsed * @throws RuntimeException on error */ @Override public void setExtra(final byte[] extra) throws RuntimeException { try { final ZipExtraField[] local = ExtraFieldUtils.parse(extra, true, ExtraFieldUtils.UnparseableExtraField.READ); mergeExtraFields(local, true); } catch (final ZipException e) { // actually this is not possible as of Commons Compress 1.1 throw new RuntimeException("Error parsing extra fields for entry: " //NOSONAR + getName() + " - " + e.getMessage(), e); } }
/** * Parses the given bytes as extra field data and consumes any * unparseable data as an {@link UnparseableExtraFieldData} * instance. * * @param extra an array of bytes to be parsed into extra fields * @throws RuntimeException if the bytes cannot be parsed * @throws RuntimeException on error * @since 1.1 */ @Override public void setExtra(final byte[] extra) throws RuntimeException { try { final ZipExtraField[] local = ExtraFieldUtils.parse(extra, true, ExtraFieldUtils.UnparseableExtraField.READ); mergeExtraFields(local, true); } catch (final ZipException e) { // actually this is not be possible as of Ant 1.8.1 throw new RuntimeException("Error parsing extra fields for entry: " //NOSONAR + getName() + " - " + e.getMessage(), e); } }
/** * Parses the given bytes as extra field data and consumes any * unparseable data as an {@link UnparseableExtraFieldData} * instance. * @param extra an array of bytes to be parsed into extra fields * @throws RuntimeException if the bytes cannot be parsed * @since 1.1 * @throws RuntimeException on error */ @Override public void setExtra(byte[] extra) throws RuntimeException { try { ZipExtraField[] local = ExtraFieldUtils.parse(extra, true, ExtraFieldUtils.UnparseableExtraField.READ); mergeExtraFields(local, true); } catch (ZipException e) { // actually this is not be possible as of Ant 1.8.1 throw new RuntimeException("Error parsing extra fields for entry: " + getName() + " - " + e.getMessage(), e); } }
if (!ze.getMessage().contains("duplicate")) { throw ze;
inflateStream.close(); } catch(java.util.zip.ZipException zex) { directory.addError(String.format("Exception decompressing PNG iCCP chunk : %s", zex.getMessage())); metadata.addDirectory(directory); textBytes = null; PngDirectory directory = new PngDirectory(PngChunkType.zTXt); directory.addError(String.format("Exception decompressing PNG zTXt chunk with keyword \"%s\": %s", keyword, zex.getMessage())); metadata.addDirectory(directory); textBytes = null; PngDirectory directory = new PngDirectory(PngChunkType.iTXt); directory.addError(String.format("Exception decompressing PNG iTXt chunk with keyword \"%s\": %s", keyword, zex.getMessage())); metadata.addDirectory(directory);
public ZipArchive(final File zipfile) throws IOException { try { this.zipfile = new ZipFile(zipfile); } catch (final ZipException ex) { final IOException exx = new IOException(ex.getMessage()); exx.initCause(ex); throw exx; } }
public static BufferedInputStream getInputStreamFromUri(URI uri) throws IOException { try { String uriStr = uri.toString().toLowerCase(); return new BufferedInputStream(uriStr.endsWith(".gz") || uriStr.endsWith(".gzip") ? new GZIPInputStream(uri.toURL().openStream()) : uri.toURL().openStream()); } catch (ZipException e) { log.error("URI {} target could not be uncompressed: {}", uri, e.getMessage()); throw e; } }
private void addToZip(JarOutputStream out, ZipEntry entry, InputStream in) throws IOException { try{ out.putNextEntry(entry); IOUtils.copy(in, out); out.closeEntry(); }catch(ZipException e){ if (e.getMessage().startsWith("duplicate entry")){ // A Jar with the same name was already added. Let's add this one using a modified name: final ZipEntry alternativeEntry = new ZipEntry(entry.getName() + "-DUPLICATE-FILENAME-" + alternativeEntryCounter.incrementAndGet() + ".jar"); addToZip(out, alternativeEntry, in); }else{ throw e; } } }
ZipArchiveEntry getNextEntry() throws IOException { if (!(in instanceof ZipArchiveInputStream)) { throw new IllegalStateException("getNextEntry() is only allowed for stream based zip processing."); } try { entry = ((ZipArchiveInputStream) in).getNextZipEntry(); return entry; } catch (ZipException ze) { if (ze.getMessage().startsWith("Unexpected record signature")) { throw new NotOfficeXmlFileException( "No valid entries or contents found, this is not a valid OOXML (Office Open XML) file", ze); } throw ze; } }
/** * Sets the central directory part of extra fields. */ public void setCentralDirectoryExtra(byte[] b) { try { ZipExtraField[] central = ExtraFieldUtils.parse(b, false, ExtraFieldUtils.UnparseableExtraField.READ); mergeExtraFields(central, false); } catch (ZipException e) { throw new RuntimeException(e.getMessage(), e); } }
/** * Sets the central directory part of extra fields. * @param b an array of bytes to be parsed into extra fields */ public void setCentralDirectoryExtra(final byte[] b) { try { final ZipExtraField[] central = ExtraFieldUtils.parse(b, false, ExtraFieldUtils.UnparseableExtraField.READ); mergeExtraFields(central, false); } catch (final ZipException e) { throw new RuntimeException(e.getMessage(), e); //NOSONAR } }
/** * Sets the central directory part of extra fields. * @param b an array of bytes to be parsed into extra fields */ public void setCentralDirectoryExtra(final byte[] b) { try { final ZipExtraField[] central = ExtraFieldUtils.parse(b, false, ExtraFieldUtils.UnparseableExtraField.READ); mergeExtraFields(central, false); } catch (final ZipException e) { throw new RuntimeException(e.getMessage(), e); //NOSONAR } }