- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.commons.compress.archivers.zip.ZipArchiveEntry
类的一些代码示例,展示了ZipArchiveEntry
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipArchiveEntry
类的具体详情如下:
包路径:org.apache.commons.compress.archivers.zip.ZipArchiveEntry
类名称:ZipArchiveEntry
[英]Extension that adds better handling of extra fields and provides access to the internal and external file attributes.
The extra data is expected to follow the recommendation of APPNOTE.TXT:
Any extra data that cannot be parsed by the rules above will be consumed as "unparseable" extra data and treated differently by the methods of this class. Versions prior to Apache Commons Compress 1.1 would have thrown an exception if any attempt was made to read or write extra data not conforming to the recommendation.
[中]扩展名,可以更好地处理额外字段,并提供对内部和外部文件属性的访问。
预计额外数据将遵循APPNOTE.TXT的建议:
*额外字节数组由一系列额外字段组成
*每个额外字段的开头是一个两字节的头id,后面是一个两字节的序列,其中包含剩余数据的长度。
上述规则无法解析的任何额外数据都将作为“不可解析”的额外数据使用,并由此类的方法进行不同的处理。如果试图读取或写入不符合建议的额外数据,Apache Commons Compress 1.1之前的版本会引发异常。
代码示例来源:origin: plutext/docx4j
log.info( "Couldn't find " + f.getPath() );
zf = new ZipFile(f);
} catch (IOException ioe) {
ioe.printStackTrace() ;
Enumeration entries = zf.getEntries();
while (entries.hasMoreElements()) {
ZipArchiveEntry entry = (ZipArchiveEntry) entries.nextElement();
policePartSize(f, entry.getSize(), entry.getName());
InputStream in = null;
try {
byte[] bytes = getBytesFromInputStream( zf.getInputStream(entry) );
policePartSize(f, bytes.length, entry.getName()); // in case earlier check ineffective
partByteArrays.put(entry.getName(), new ByteArray(bytes) );
} catch (PartTooLargeException e) {
throw e;
代码示例来源:origin: org.apache.poi/poi-ooxml
protected void injectData(ZipEntrySource zipEntrySource, OutputStream out) throws IOException {
ZipArchiveOutputStream zos = new ZipArchiveOutputStream(out);
try {
Enumeration<? extends ZipArchiveEntry> en = zipEntrySource.getEntries();
while (en.hasMoreElements()) {
ZipArchiveEntry ze = en.nextElement();
ZipArchiveEntry zeOut = new ZipArchiveEntry(ze.getName());
zeOut.setSize(ze.getSize());
zeOut.setTime(ze.getTime());
zos.putArchiveEntry(zeOut);
try (final InputStream is = zipEntrySource.getInputStream(ze)) {
if (is instanceof ZipArchiveThresholdInputStream) {
XSSFSheet xSheet = getSheetFromZipEntryName(ze.getName());
zos.closeArchiveEntry();
代码示例来源: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) {
final Enumeration<ZipArchiveEntry> entries = zip.getEntries();
while (entries.hasMoreElements()) {
final ZipArchiveEntry entry = entries.nextElement();
if (!entry.isDirectory()) {
final String name = entry.getName().toLowerCase();
if (name.endsWith(".class")) {
isJar = true;
代码示例来源:origin: org.apache.commons/commons-compress
private boolean isTooLageForZip32(final ZipArchiveEntry zipArchiveEntry){
return zipArchiveEntry.getSize() >= ZIP64_MAGIC || zipArchiveEntry.getCompressedSize() >= ZIP64_MAGIC;
}
代码示例来源:origin: org.apache.commons/commons-compress
/**
* Sets Unix permissions in a way that is understood by Info-Zip's
* unzip command.
* @param mode an <code>int</code> value
*/
public void setUnixMode(final int mode) {
// CheckStyle:MagicNumberCheck OFF - no point
setExternalAttributes((mode << SHORT_SHIFT)
// MS-DOS read-only attribute
| ((mode & 0200) == 0 ? 1 : 0)
// MS-DOS directory flag
| (isDirectory() ? 0x10 : 0));
// CheckStyle:MagicNumberCheck ON
platform = PLATFORM_UNIX;
}
代码示例来源:origin: org.apache.commons/commons-compress
/**
* If the mode is AsNeeded and the entry is a compressed entry of
* unknown size that gets written to a non-seekable stream then
* change the default to Never.
*
* @since 1.3
*/
private Zip64Mode getEffectiveZip64Mode(final ZipArchiveEntry ze) {
if (zip64Mode != Zip64Mode.AsNeeded
|| channel != null
|| ze.getMethod() != DEFLATED
|| ze.getSize() != ArchiveEntry.SIZE_UNKNOWN) {
return zip64Mode;
}
return Zip64Mode.Never;
}
代码示例来源:origin: apache/tika
private static MediaType detectKmz(ZipFile zip) {
boolean kmlFound = false;
Enumeration<ZipArchiveEntry> entries = zip.getEntries();
while (entries.hasMoreElements()) {
ZipArchiveEntry entry = entries.nextElement();
String name = entry.getName();
if (!entry.isDirectory()
&& name.indexOf('/') == -1 && name.indexOf('\\') == -1) {
if (name.endsWith(".kml") && !kmlFound) {
kmlFound = true;
} else {
return null;
}
}
}
if (kmlFound) {
return MediaType.application("vnd.google-earth.kmz");
} else {
return null;
}
}
代码示例来源:origin: org.apache.poi/poi-examples
/**
*
* @param zipfile the template file
* @param tmpfile the XML file with the sheet data
* @param entry the name of the sheet entry to substitute, e.g. xl/worksheets/sheet1.xml
* @param out the stream to write the result to
*/
private static void substitute(File zipfile, File tmpfile, String entry, OutputStream out) throws IOException {
try (ZipFile zip = ZipHelper.openZipFile(zipfile)) {
try (ZipArchiveOutputStream zos = new ZipArchiveOutputStream(out)) {
Enumeration<? extends ZipArchiveEntry> en = zip.getEntries();
while (en.hasMoreElements()) {
ZipArchiveEntry ze = en.nextElement();
if (!ze.getName().equals(entry)) {
zos.putArchiveEntry(new ZipArchiveEntry(ze.getName()));
try (InputStream is = zip.getInputStream(ze)) {
copyStream(is, zos);
}
zos.closeArchiveEntry();
}
}
zos.putArchiveEntry(new ZipArchiveEntry(entry));
try (InputStream is = new FileInputStream(tmpfile)) {
copyStream(is, zos);
}
zos.closeArchiveEntry();
}
}
}
代码示例来源:origin: apache/tika
private static MediaType tryStreamingDetection(TikaInputStream stream) {
Set<String> entryNames = new HashSet<>();
try (InputStream is = new FileInputStream(stream.getFile())) {
ZipArchiveInputStream zipArchiveInputStream = new ZipArchiveInputStream(is);
ZipArchiveEntry zae = zipArchiveInputStream.getNextZipEntry();
while (zae != null) {
if (zae.isDirectory()) {
zae = zipArchiveInputStream.getNextZipEntry();
continue;
entryNames.add(zae.getName());
if (zae.getName().equals("[Content_Types].xml")) {
MediaType mt = parseContentTypes(zipArchiveInputStream);
if (mt != null) {
代码示例来源:origin: biezhi/java-library-examples
private static void addToArchiveCompression(ZipArchiveOutputStream out, File file, String dir) throws IOException {
String name = dir + File.separator + file.getName();
if (file.isFile()) {
ZipArchiveEntry entry = new ZipArchiveEntry(name);
out.putArchiveEntry(entry);
entry.setSize(file.length());
IOUtils.copy(new FileInputStream(file), out);
out.closeArchiveEntry();
} else if (file.isDirectory()) {
File[] children = file.listFiles();
if (children != null) {
for (File child : children) {
addToArchiveCompression(out, child, name);
}
}
} else {
System.out.println(file.getName() + " is not supported");
}
}
代码示例来源:origin: org.codehaus.plexus/plexus-archiver
try
zipFile = new org.apache.commons.compress.archivers.zip.ZipFile( getSourceFile(), encoding, true );
final Enumeration e = zipFile.getEntriesInPhysicalOrder();
while ( e.hasMoreElements() )
final ZipArchiveEntry ze = (ZipArchiveEntry) e.nextElement();
final ZipEntryFileInfo fileInfo = new ZipEntryFileInfo( zipFile, ze );
if ( !isSelected( ze.getName(), fileInfo ) )
if ( ze.getName().startsWith( path ) )
in = zipFile.getInputStream( ze );
ze.getName(), new Date( ze.getTime() ), ze.isDirectory(),
ze.getUnixMode() != 0 ? ze.getUnixMode() : null,
resolveSymlink( zipFile, ze ), getFileMappers() );
代码示例来源:origin: apache/incubator-gobblin
@edu.umd.cs.findbugs.annotations.SuppressWarnings(
value = "OBL_UNSATISFIED_OBLIGATION",
justification = "Lombok construct of @Cleanup is handing this, but not detected by FindBugs")
private static void addFilesToZip(File zipFile, List<File> filesToAdd) throws IOException {
try {
@Cleanup
OutputStream archiveStream = new FileOutputStream(zipFile);
@Cleanup
ArchiveOutputStream archive =
new ArchiveStreamFactory().createArchiveOutputStream(ArchiveStreamFactory.ZIP, archiveStream);
for (File fileToAdd : filesToAdd) {
ZipArchiveEntry entry = new ZipArchiveEntry(fileToAdd.getName());
archive.putArchiveEntry(entry);
@Cleanup
BufferedInputStream input = new BufferedInputStream(new FileInputStream(fileToAdd));
IOUtils.copy(input, archive);
archive.closeArchiveEntry();
}
archive.finish();
} catch (ArchiveException e) {
throw new IOException("Issue with creating archive", e);
}
}
代码示例来源:origin: walmartlabs/concord
public static void unzip(Path in, Path targetDir, boolean skipExisting, CopyOption... options) throws IOException {
try (ZipFile zip = new ZipFile(in.toFile())) {
Enumeration<ZipArchiveEntry> entries = zip.getEntries();
while (entries.hasMoreElements()) {
ZipArchiveEntry e = entries.nextElement();
Path p = targetDir.resolve(e.getName());
if (skipExisting && Files.exists(p)) {
continue;
}
if (e.isDirectory()) {
Files.createDirectories(p);
} else {
Path parent = p.getParent();
if (!Files.exists(parent)) {
Files.createDirectories(parent);
}
try (InputStream src = zip.getInputStream(e)) {
Files.copy(src, p, options);
}
int unixMode = e.getUnixMode();
if (unixMode <= 0) {
unixMode = Posix.DEFAULT_UNIX_MODE;
}
Files.setPosixFilePermissions(p, Posix.posix(unixMode));
}
}
}
}
代码示例来源:origin: apache/tika
private static InputStream getZipStream(String zipPath, ZipPackage zipPackage) throws IOException, TikaException {
String targPath = (zipPath.length() > 1 && zipPath.startsWith("/") ? zipPath.substring(1) : zipPath);
ZipEntrySource zipEntrySource = zipPackage.getZipArchive();
Enumeration<? extends ZipArchiveEntry> zipEntryEnumeration = zipEntrySource.getEntries();
ZipArchiveEntry zipEntry = null;
while (zipEntryEnumeration.hasMoreElements()) {
ZipArchiveEntry ze = zipEntryEnumeration.nextElement();
if (ze.getName().equals(targPath)) {
zipEntry = ze;
break;
}
}
if (zipEntry == null) {
throw new TikaException("Couldn't find required zip entry: " + zipPath);
}
return zipEntrySource.getInputStream(zipEntry);
}
}
代码示例来源:origin: naver/ngrinder
ZipArchiveOutputStream zos = new ZipArchiveOutputStream(os);
zos.setEncoding(charsetName);
FileInputStream fis = null;
ze = new ZipArchiveEntry(name);
zos.putArchiveEntry(ze);
try {
fis = new FileInputStream(f);
while ((length = fis.read(buf, 0, buf.length)) >= 0) {
zos.write(buf, 0, length);
代码示例来源:origin: apache/tika
private static void repairCopy(File brokenZip, File fixedZip) {
try (ZipArchiveOutputStream outputStream = new ZipArchiveOutputStream(fixedZip)) {
try (InputStream is = new FileInputStream(brokenZip)) {
ZipArchiveInputStream zipArchiveInputStream = new ZipArchiveInputStream(is);
ZipArchiveEntry zae = zipArchiveInputStream.getNextZipEntry();
while (zae != null) {
try {
if (!zae.isDirectory() && zipArchiveInputStream.canReadEntryData(zae)) {
outputStream.putArchiveEntry(zae);
outputStream.flush();
outputStream.closeArchiveEntry();
if (!successfullyCopied) {
代码示例来源:origin: de.flapdoodle.embedmongo/de.flapdoodle.embedmongo
progressListener.start(progressLabel);
FileInputStream fin = new FileInputStream(source);
BufferedInputStream in = new BufferedInputStream(fin);
ZipArchiveInputStream zipIn = new ZipArchiveInputStream(in);
try {
ZipArchiveEntry entry;
while ((entry = zipIn.getNextZipEntry()) != null) {
if (file.matcher(entry.getName()).matches()) {
if (zipIn.canReadEntryData(entry)) {
long size = entry.getSize();
Files.write(zipIn, size, destination);
destination.setExecutable(true);
代码示例来源:origin: USPTO/PatentPublicData
public ZipArchiveEntry nextEntry() {
while (hasNext()) {
currentEntry = entries.nextElement();
File entryFile = new File(currentEntry.getName());
if (filter.accept(entryFile)) {
return currentEntry;
}
}
throw new NoSuchElementException();
}
代码示例来源:origin: org.apache.poi/poi-ooxml
Cipher ciEnc = CryptoFunctions.getCipher(skeySpec, CipherAlgorithm.aes128, ChainingMode.cbc, ivBytes, Cipher.ENCRYPT_MODE, PADDING);
ZipArchiveInputStream zis = new ZipArchiveInputStream(is);
FileOutputStream fos = new FileOutputStream(tmpFile);
ZipArchiveOutputStream zos = new ZipArchiveOutputStream(fos);
while ((ze = zis.getNextZipEntry()) != null) {
ZipArchiveEntry zeNew = new ZipArchiveEntry(ze.getName());
zeNew.setComment(ze.getComment());
zeNew.setExtra(ze.getExtra());
zeNew.setTime(ze.getTime());
zos.putArchiveEntry(zeNew);
FilterOutputStream fos2 = new FilterOutputStream(zos) {
cos.close();
fos2.close();
zos.closeArchiveEntry();
zos.close();
fos.close();
zis.close();
代码示例来源:origin: plutext/docx4j
public void saveContentTypes(ContentTypeManager ctm) throws Docx4JException {
try {
zos.putArchiveEntry(new ZipArchiveEntry("[Content_Types].xml"));
ctm.marshal(zos);
zos.closeArchiveEntry();
} catch (Exception e) {
throw new Docx4JException("Error marshalling Content_Types ", e);
}
}
最近,我开始学习 cuis-smalltalk,我没有意识到与 CLOS 相比,Smalltalk 的 OOP 有多么深刻和深入(我使用的是 Ruby)。我了解到 Smalltalk 是一个自己实现的
Maven存储库包含以下两个依赖项:org.apache.commons:commons-io:1.3.2和commons-io:commons-io:1.3.2。有什么区别,我应该在pom.xml中
我刚刚在我的 pom 文件中看到 Apache commons-collections 有两个不同的组 ID: commons-collections commons-collect
Windows 上的 Common Lisp 中是否有用于串行端口通信的库? 最佳答案 下面是一些使用 SBCL 外部函数 POSIX 调用实现串行通信的函数。它不如完整的库好,但我解决了根据此协议(
SBCL 64位,1.1.7 如果我想创建一个包并使用package:CL中的一些符号,我将创建一个像这样的包: (defpackage :foo (:import-from :cl
我正在忙着学习Common Lisp,并且正在寻找一种静态代码分析工具,该工具将帮助我开发更好的样式并避免陷入常见的陷阱。 我找到了Lisp Critic,看起来不错,但我希望有人可以推荐其他一些工具
我正在阅读《Practical Common Lisp》一书,在第 22 章第 284 页的脚注 5 中,我看到一段让我感到困惑的代码片段。 我知道变量list和tail有一个共同的列表结构,但我很困
我正在阅读 Practical Common Lisp ,并且对 Lisp 的 COPY-TREE 函数有疑问。 书中给出了调用的例子 (copy-tree '( '(1 2) '(3 4) '(5
我正在尝试使用 user guide 中的抓取示例运行 geb用于引入依赖项: $ cat my.groovy @Grapes([ @Grab("org.gebish:geb-core:0.9
这里一定有更好的方法,对吧? (format t "Enter your age: ~%") (defun age-case (age) (case age (1 (format t "Y
如何在 do 循环中绑定(bind)从函数返回的多个值? 以下显然是非常错误的,但是这样的事情可能吗? (do (((x y z) (3-val-fn) (3-val-fn))) ((equa
所以我正在学习 Lisp 做分数,这很棒。但是为什么这个相等性检查返回 NIL: * (= 0.2 1/5) NIL ...如果转换为 float 则返回 True第一的: * (=
是否可以“统计”一个文件并找到它的文件类型 - 常规或目录? 最佳答案 阅读关于 portable pathname library 的章节来自 Peter Seibel 的 Practical Co
我是 CL 的新手,正在使用 AllegroCL。我试图弄清楚如何组织我的源代码以满足以下要求: 我想阻止 src 代码包含我的测试套件。 我想以可移植的方式声明项目依赖项(src 和 test de
谁能告诉我最新的标准化 Common Lisp 的文档是什么(应该遵循各种实现的文档)?我问是因为我可以在网上找到很多关于 CL 的书都来自 90 年代,所以我想知道它们是否是最新的。我也来自于在 R
假设我必须定义一个名为foo 的函数。假设,为了定义它,我使用了一些辅助函数 foo1, foo2, foo3, ... 当我加载包含这些函数的文件时,我可以从顶层使用所有这些函数。相反,我只想从顶层
这拒绝编译。注释掉 (setf roll行让它编译。然而,(setf roll...本身在 REPL 中正确评估。 程序: ;; loop n times ; sum up number of hit
我目前正在学习 Common Lisp,并尝试将一些 JSON 发送到网络服务。我要发送的 JSON 以类似于以下的结构表示: ((:ITEMS ((:KEY . "value1") (:IGNO
我有一个带波浪号的目录名(作为字符串):~/projects . 我想得到它的完整路径:/home/user/projects .我怎么做 ? 目标是将它传递给 uiop:run-program ,这
我想从输入文件中读取一个字符串(用户可能修改也可能没有修改)。我想将此字符串视为使用固定数量的参数调用的格式指令。但是,我知道某些格式指令(特别是我想到的 ~/)可能会用于注入(inject)函数调用
我是一名优秀的程序员,十分优秀!