private AesZipFileZipEntrySource(File tmpFile, Cipher ci) throws IOException { this.tmpFile = tmpFile; this.zipFile = new ZipFile(tmpFile); this.ci = ci; this.closed = false; }
public static void decompressZipfileToDirectory(String zipFileName, File outputFolder) throws IOException, ArchiveException { if (!validateZipFilename(zipFileName)) { throw new RuntimeException("Zip file must end with .zip"); } Expander expander = new Expander(); ZipFile zipFile = new ZipFile(zipFileName); expander.expand(zipFile, outputFolder); }
ZipFile zip = null; try { zip = new ZipFile(dependency.getActualFilePath()); if (zip.getEntry("META-INF/MANIFEST.MF") != null || zip.getEntry("META-INF/maven") != null) {
log.info( "Couldn't find " + f.getPath() ); zf = new ZipFile(f); } catch (IOException ioe) { ioe.printStackTrace() ;
/** * Expands {@code archive} into {@code targetDirectory}. * * @param archive the file to expand * @param targetDirectory the directory to write to * @param format the archive format. This uses the same format as * accepted by {@link ArchiveStreamFactory}. * @throws IOException if an I/O error occurs * @throws ArchiveException if the archive cannot be read for other reasons */ public void expand(String format, SeekableByteChannel archive, File targetDirectory) throws IOException, ArchiveException { if (!prefersSeekableByteChannel(format)) { expand(format, Channels.newInputStream(archive), targetDirectory); } else if (ArchiveStreamFactory.ZIP.equalsIgnoreCase(format)) { expand(new ZipFile(archive), targetDirectory); } else if (ArchiveStreamFactory.SEVEN_Z.equalsIgnoreCase(format)) { expand(new SevenZFile(archive), targetDirectory); } else { // never reached as prefersSeekableByteChannel only returns true for ZIP and 7z throw new ArchiveException("don't know how to handle format " + format); } }
@Override protected Iterator<PlexusIoResource> getEntries() throws IOException { final File f = getFile(); if ( f == null ) { throw new IOException( "The tar archive file has not been set." ); } final ZipFile zipFile = new ZipFile( f, charset != null ? charset.name() : "UTF8" ); return new CloseableIterator( zipFile ); }
@Override protected Iterator<PlexusIoResource> getEntries() throws IOException { final File f = getFile(); if ( f == null ) { throw new IOException( "The zip file has not been set." ); } final URLClassLoader urlClassLoader = new URLClassLoader( new URL[] { f.toURI().toURL() }, null ) { @Override public URL getResource( String name ) { return findResource( name ); } }; final URL url = new URL( "jar:" + f.toURI().toURL() + "!/" ); final JarFile jarFile = new JarFile( f ); final ZipFile zipFile = new ZipFile( f, charset != null ? charset.name() : "UTF8" ); final Enumeration<ZipArchiveEntry> en = zipFile.getEntriesInPhysicalOrder(); return new ZipFileResourceIterator( en, url, jarFile, zipFile, urlClassLoader ); }
try zf = new org.apache.commons.compress.archivers.zip.ZipFile( file, "utf-8" ); Enumeration<ZipArchiveEntry> entries = zf.getEntries(); HashSet<String> dirSet = new HashSet<String>();
protected Map<String, String> readZipArchive(InputStream inputStream) throws IOException { Map<String, String> data = new HashMap<String, String>(); Path tempFile = writeTemporaryArchiveFile(inputStream, "zip"); ZipFile zip = new ZipFile(tempFile.toFile()); Enumeration<ZipArchiveEntry> entries = zip.getEntries(); while (entries.hasMoreElements()) { ZipArchiveEntry entry = entries.nextElement(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); IOUtils.copy(zip.getInputStream(entry), bos); data.put(entry.getName(), DigestUtils.md5Hex(bos.toByteArray())); } zip.close(); Files.delete(tempFile); return data; }
protected String readArchiveText(InputStream inputStream) throws IOException { Path tempFile = writeTemporaryArchiveFile(inputStream, "zip"); ZipFile zip = new ZipFile(tempFile.toFile()); zip.getEntry(UnpackerResource.TEXT_FILENAME); ByteArrayOutputStream bos = new ByteArrayOutputStream(); IOUtils.copy(zip.getInputStream(zip.getEntry(UnpackerResource.TEXT_FILENAME)), bos); zip.close(); Files.delete(tempFile); return bos.toString(UTF_8.name()); }
zipFile = (ZipFile) container; } else if (tis.hasFile()) { zipFile = new ZipFile(tis.getFile()); } else { zipStream = new ZipInputStream(stream);
try zipFile = new org.apache.commons.compress.archivers.zip.ZipFile( getSourceFile(), encoding, true );
zipEntrySource = new ZipFileZipEntrySource(new ZipFile(stream.getFile())); } catch (IOException e) { return tryStreamingDetection(stream);
try zf = new org.apache.commons.compress.archivers.zip.ZipFile( getSourceFile(), encoding, true ); final Enumeration e = zf.getEntriesInPhysicalOrder(); while ( e.hasMoreElements() )
return type; ZipFile zip = new ZipFile(tis.getFile()); // TODO: hasFile()? try { type = detectOpenDocument(zip);
@Override protected ArchiveWrapper archiveStream(File source) throws IOException { ZipFile zipIn = new ZipFile(source); return new ZipArchiveWrapper(zipIn); }
@Override protected ArchiveWrapper archiveStream(File source) throws IOException { ZipFile zipIn = new ZipFile(source); return new ZipArchiveWrapper(zipIn); }
/** * @param file the XAR file * @param xarPackage the descriptor of the XAR package * @throws XarException when failing parse the file (for example if it's not a valid XAR package) * @throws IOException when failing to read file */ public XarFile(File file, XarPackage xarPackage) throws XarException, IOException { this.file = file; this.zipFile = new ZipFile(file); this.xarPackage = xarPackage != null ? xarPackage : new XarPackage(this.zipFile); }
public void printContents(PrintStream ps) throws IOException { ZipFile zipFile = new ZipFile(this); /* First create all directories */ Enumeration entries = zipFile.getEntries(); while (entries.hasMoreElements()) { ZipArchiveEntry entry = (ZipArchiveEntry) entries.nextElement(); ps.println(entry.getName()); } }
private void validateBagFile(File bagFile) throws IOException { // Run a confirmation test - should verify all files and hashes ZipFile zf = new ZipFile(bagFile); // Check files calculates the hashes and file sizes and reports on // whether hashes are correct checkFiles(checksumMap, zf); logger.info("Data Count: " + dataCount); logger.info("Data Size: " + totalDataSize); zf.close(); }