- 使用 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);
}
}
我尝试理解[c代码 -> 汇编]代码 void node::Check( data & _data1, vector& _data2) { -> push ebp -> mov ebp,esp ->
我需要在当前表单(代码)的上下文中运行文本文件中的代码。其中一项要求是让代码创建新控件并将其添加到当前窗体。 例如,在Form1.cs中: using System.Windows.Forms; ..
我有此 C++ 代码并将其转换为 C# (.net Framework 4) 代码。有没有人给我一些关于 malloc、free 和 sprintf 方法的提示? int monate = ee; d
我的网络服务器代码有问题 #include #include #include #include #include #include #include int
给定以下 html 代码,将列表中的第三个元素(即“美丽”一词)以斜体显示的 CSS 代码是什么?当然,我可以给这个元素一个 id 或一个 class,但 html 代码必须保持不变。谢谢
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
我试图制作一个宏来避免重复代码和注释。 我试过这个: #define GrowOnPage(any Page, any Component) Component.Width := Page.Surfa
我正在尝试将我的旧 C++ 代码“翻译”成头条新闻所暗示的 C# 代码。问题是我是 C# 中的新手,并不是所有的东西都像 C++ 中那样。在 C++ 中这些解决方案运行良好,但在 C# 中只是不能。我
在 Windows 10 上工作,R 语言的格式化程序似乎没有在 Visual Studio Code 中完成它的工作。我试过R support for Visual Studio Code和 R-T
我正在处理一些报告(计数),我必须获取不同参数的计数。非常简单但乏味。 一个参数的示例查询: qCountsEmployee = ( "select count(*) from %s wher
最近几天我尝试从 d00m 调试网络错误。我开始用尽想法/线索,我希望其他 SO 用户拥有可能有用的宝贵经验。我希望能够提供所有相关信息,但我个人无法控制服务器环境。 整个事情始于用户注意到我们应用程
我有一个 app.js 文件,其中包含如下 dojo amd 模式代码: require(["dojo/dom", ..], function(dom){ dom.byId('someId').i
我对“-gencode”语句中的“code=sm_X”选项有点困惑。 一个例子:NVCC 编译器选项有什么作用 -gencode arch=compute_13,code=sm_13 嵌入库中? 只有
我为我的表格使用 X-editable 框架。 但是我有一些问题。 $(document).ready(function() { $('.access').editable({
我一直在通过本教程学习 flask/python http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-wo
我想将 Vim 和 EMACS 用于 CNC、G 代码和 M 代码。 Vim 或 EMACS 是否有任何语法或模式来处理这种类型的代码? 最佳答案 一些快速搜索使我找到了 this vim 和 thi
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?更新问题,使其成为 on-topic对于堆栈溢出。 7年前关闭。 Improve this
这个问题在这里已经有了答案: Enabling markdown highlighting in Vim (5 个回答) 6年前关闭。 当我在 Vim 中编辑包含 Markdown 代码的 READM
我正在 Swift3 iOS 中开发视频应用程序。基本上我必须将视频 Assets 和音频与淡入淡出效果合并为一个并将其保存到 iPhone 画廊。为此,我使用以下方法: private func d
pipeline { agent any stages { stage('Build') { steps { e
我是一名优秀的程序员,十分优秀!