本文整理了Java中org.apache.commons.compress.archivers.zip.ZipFile.<init>()
方法的一些代码示例,展示了ZipFile.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipFile.<init>()
方法的具体详情如下:
包路径:org.apache.commons.compress.archivers.zip.ZipFile
类名称:ZipFile
方法名:<init>
[英]Opens the given file for reading, assuming "UTF8" for file names.
[中]打开给定文件进行读取,假定文件名为“UTF8”。
代码示例来源:origin: org.apache.poi/poi-ooxml
private AesZipFileZipEntrySource(File tmpFile, Cipher ci) throws IOException {
this.tmpFile = tmpFile;
this.zipFile = new ZipFile(tmpFile);
this.ci = ci;
this.closed = false;
}
代码示例来源:origin: apache/kylin
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);
}
代码示例来源:origin: jeremylong/DependencyCheck
ZipFile zip = null;
try {
zip = new ZipFile(dependency.getActualFilePath());
if (zip.getEntry("META-INF/MANIFEST.MF") != null
|| zip.getEntry("META-INF/maven") != null) {
代码示例来源:origin: plutext/docx4j
log.info( "Couldn't find " + f.getPath() );
zf = new ZipFile(f);
} catch (IOException ioe) {
ioe.printStackTrace() ;
代码示例来源:origin: org.apache.commons/commons-compress
/**
* 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);
}
}
代码示例来源:origin: org.codehaus.plexus/plexus-archiver
@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 );
}
代码示例来源:origin: org.codehaus.plexus/plexus-archiver
@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 );
}
代码示例来源:origin: org.codehaus.plexus/plexus-archiver
try
zf = new org.apache.commons.compress.archivers.zip.ZipFile( file, "utf-8" );
Enumeration<ZipArchiveEntry> entries = zf.getEntries();
HashSet<String> dirSet = new HashSet<String>();
代码示例来源:origin: apache/tika
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;
}
代码示例来源:origin: apache/tika
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());
}
代码示例来源:origin: apache/tika
zipFile = (ZipFile) container;
} else if (tis.hasFile()) {
zipFile = new ZipFile(tis.getFile());
} else {
zipStream = new ZipInputStream(stream);
代码示例来源:origin: org.codehaus.plexus/plexus-archiver
try
zipFile = new org.apache.commons.compress.archivers.zip.ZipFile( getSourceFile(), encoding, true );
代码示例来源:origin: apache/tika
zipEntrySource = new ZipFileZipEntrySource(new ZipFile(stream.getFile()));
} catch (IOException e) {
return tryStreamingDetection(stream);
代码示例来源:origin: org.codehaus.plexus/plexus-archiver
try
zf = new org.apache.commons.compress.archivers.zip.ZipFile( getSourceFile(), encoding, true );
final Enumeration e = zf.getEntriesInPhysicalOrder();
while ( e.hasMoreElements() )
代码示例来源:origin: apache/tika
return type;
ZipFile zip = new ZipFile(tis.getFile()); // TODO: hasFile()?
try {
type = detectOpenDocument(zip);
代码示例来源:origin: de.flapdoodle.embed/de.flapdoodle.embed.process
@Override
protected ArchiveWrapper archiveStream(File source) throws IOException {
ZipFile zipIn = new ZipFile(source);
return new ZipArchiveWrapper(zipIn);
}
代码示例来源:origin: flapdoodle-oss/de.flapdoodle.embed.process
@Override
protected ArchiveWrapper archiveStream(File source) throws IOException {
ZipFile zipIn = new ZipFile(source);
return new ZipArchiveWrapper(zipIn);
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-xar-model
/**
* @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);
}
代码示例来源:origin: com.comcast.pantry/pantry
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());
}
}
代码示例来源:origin: IQSS/dataverse
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();
}
内容来源于网络,如有侵权,请联系作者删除!