- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中java.util.zip.ZipInputStream.getNextEntry()
方法的一些代码示例,展示了ZipInputStream.getNextEntry()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipInputStream.getNextEntry()
方法的具体详情如下:
包路径:java.util.zip.ZipInputStream
类名称:ZipInputStream
方法名:getNextEntry
[英]Returns the next entry from this ZipInputStream or null if no more entries are present.
[中]返回此ZipInputStream中的下一个条目,如果没有更多条目,则返回null。
代码示例来源:origin: gocd/gocd
public String getFileContentInsideZip(ZipInputStream zipInputStream, String file) throws IOException {
ZipEntry zipEntry = zipInputStream.getNextEntry();
while (zipEntry != null) {
if (new File(zipEntry.getName()).getName().equals(file)) {
return IOUtils.toString(zipInputStream, UTF_8);
}
zipEntry = zipInputStream.getNextEntry();
}
return null;
}
代码示例来源:origin: spotbugs/spotbugs
private void getNextEntry() throws IOException {
ze = zis.getNextEntry();
if (ze == null) {
zis.close();
}
}
代码示例来源:origin: stackoverflow.com
List<String> classNames = new ArrayList<String>();
ZipInputStream zip = new ZipInputStream(new FileInputStream("/path/to/jar/file.jar"));
for (ZipEntry entry = zip.getNextEntry(); entry != null; entry = zip.getNextEntry()) {
if (!entry.isDirectory() && entry.getName().endsWith(".class")) {
// This ZipEntry represents a class. Now, what class does it represent?
String className = entry.getName().replace('/', '.'); // including ".class"
classNames.add(className.substring(0, className.length() - ".class".length()));
}
}
代码示例来源:origin: apache/ignite
/**
* @param zip Compressed file.
*/
public UnzipFileIO(File zip) throws IOException {
zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(zip)));
ZipEntry entry = zis.getNextEntry();
size = entry.getSize();
}
代码示例来源:origin: geoserver/geoserver
public static void decompress(InputStream input, File destDir) throws IOException {
ZipInputStream zin = new ZipInputStream(input);
ZipEntry entry = null;
byte[] buffer = new byte[1024];
while ((entry = zin.getNextEntry()) != null) {
File f = getZipOutputFile(destDir, entry);
if (entry.isDirectory()) {
f.mkdirs();
continue;
}
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(f));
int n = -1;
while ((n = zin.read(buffer)) != -1) {
out.write(buffer, 0, n);
}
out.flush();
out.close();
}
}
代码示例来源:origin: stackoverflow.com
CodeSource src = MyClass.class.getProtectionDomain().getCodeSource();
if (src != null) {
URL jar = src.getLocation();
ZipInputStream zip = new ZipInputStream(jar.openStream());
while(true) {
ZipEntry e = zip.getNextEntry();
if (e == null)
break;
String name = e.getName();
if (name.startsWith("path/to/your/dir/")) {
/* Do something with this entry. */
...
}
}
}
else {
/* Fail... */
}
代码示例来源:origin: org.apache.ant/ant
jarEntry = jarStream.getNextEntry();
String entryName = jarEntry.getName();
if (!jarEntry.isDirectory() && entryName.endsWith(".class")) {
jarEntry = jarStream.getNextEntry();
代码示例来源:origin: neo4j/neo4j
ZipEntry nextEntry = zip.getNextEntry();
if ( nextEntry == null )
zip.close();
return null;
String name = nextEntry.getName();
if ( name.endsWith( ".class" ) )
zip.close();
throw e;
代码示例来源:origin: h2oai/h2o-2
return bs;
case ZIP: {
ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(bs));
ZipEntry ze = zis.getNextEntry(); // Get the *FIRST* entry
if( ze != null && !ze.isDirectory() ) {
is = zis;
break;
zis.close();
return bs; // Don't crash, ignore file if cannot unzip
代码示例来源:origin: syncany/syncany
@Override
public Chunk read() throws IOException {
ZipEntry entry = zipIn.getNextEntry();
if (entry == null) {
return null;
}
int read;
ByteArrayOutputStream contentByteArray = new ByteArrayOutputStream();
while (-1 != (read = zipIn.read())) {
contentByteArray.write(read);
}
return new Chunk(StringUtil.fromHex(entry.getName()), contentByteArray.toByteArray(), contentByteArray.size(), null);
}
代码示例来源:origin: airbnb/lottie-android
ZipEntry entry = inputStream.getNextEntry();
while (entry != null) {
if (entry.getName().contains("__MACOSX")) {
inputStream.closeEntry();
} else if (entry.getName().contains(".json")) {
composition = LottieCompositionFactory.fromJsonInputStreamSync(inputStream, cacheKey, false).getValue();
} else if (entry.getName().contains(".png")) {
String[] splitName = entry.getName().split("/");
String name = splitName[splitName.length - 1];
entry = inputStream.getNextEntry();
代码示例来源:origin: apache/incubator-druid
} else if (fileName.endsWith(ZIP_SUFFIX)) {
final ZipInputStream zipIn = new ZipInputStream(in, StandardCharsets.UTF_8);
try {
final ZipEntry nextEntry = zipIn.getNextEntry();
if (nextEntry == null) {
zipIn.close();
zipIn.close();
代码示例来源:origin: stackoverflow.com
boolean isZipped = new ZipInputStream(yourInputStream).getNextEntry() != null;
代码示例来源:origin: plantuml/plantuml
private InputStream getDataFromZip(InputStream is, String name) throws IOException {
final ZipInputStream zis = new ZipInputStream(is);
ZipEntry ze = zis.getNextEntry();
while (ze != null) {
final String fileName = ze.getName();
if (ze.isDirectory()) {
} else if (fileName.equals(name)) {
return zis;
}
ze = zis.getNextEntry();
}
zis.closeEntry();
zis.close();
return null;
}
代码示例来源:origin: spotbugs/spotbugs
MyIterator() {
try {
zis = new ZipInputStream(new FileInputStream(file));
ze = zis.getNextEntry();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: stackoverflow.com
CodeSource src = MyClass.class.getProtectionDomain().getCodeSource();
List<String> list = new ArrayList<String>();
if( src != null ) {
URL jar = src.getLocation();
ZipInputStream zip = new ZipInputStream( jar.openStream());
ZipEntry ze = null;
while( ( ze = zip.getNextEntry() ) != null ) {
String entryName = ze.getName();
if( entryName.startsWith("images") && entryName.endsWith(".png") ) {
list.add( entryName );
}
}
}
webimages = list.toArray( new String[ list.size() ] );
代码示例来源:origin: Activiti/Activiti
public DeploymentBuilder addZipInputStream(ZipInputStream zipInputStream) {
try {
ZipEntry entry = zipInputStream.getNextEntry();
while (entry != null) {
if (!entry.isDirectory()) {
String entryName = entry.getName();
byte[] bytes = IoUtil.readInputStream(zipInputStream, entryName);
ResourceEntity resource = resourceEntityManager.create();
resource.setName(entryName);
resource.setBytes(bytes);
deployment.addResource(resource);
}
entry = zipInputStream.getNextEntry();
}
} catch (Exception e) {
throw new ActivitiException("problem reading zip input stream", e);
}
return this;
}
代码示例来源:origin: zeroturnaround/zt-zip
in = newCloseShieldZipInputStream(is, charset);
ZipEntry entry;
while ((entry = in.getNextEntry()) != null) {
try {
action.process(in, entry);
throw new ZipException("Failed to process zip entry '" + entry.getName() + " with action " + action, ze);
in.close();
代码示例来源:origin: nutzam/nutz
public InputStream getInputStream() throws IOException {
ZipInputStream zis = Scans.makeZipInputStream(jarPath);
ZipEntry ens = null;
while (null != (ens = zis.getNextEntry())) {
if (ens.getName().equals(entryName))
return zis;
}
throw Lang.impossible();
}
代码示例来源:origin: plantuml/plantuml
public InputStream open() throws IOException {
final ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile));
ZipEntry ze = zis.getNextEntry();
while (ze != null) {
final String fileName = ze.getName();
if (ze.isDirectory()) {
} else if (fileName.trim().equalsIgnoreCase(entry.trim())) {
return zis;
}
ze = zis.getNextEntry();
}
zis.closeEntry();
zis.close();
throw new IOException();
}
下面是代码片段。 while (iterator.hasNext()) { FileItemStream item = iterator.next(); InputStream in
我有 Java 代码,它传入一个 Zip 文件列表,其中一个文件的格式故意错误。该 Zip 文件位于列表末尾。 我的代码看起来有点像: System.out.println("Hi Stinky Pe
如果我使用包含一些带有变音符号的文件(例如 1-2GF-969##JÖN.pdf)的 zip 文件运行以下程序,我会得到 IllegalArgumentException。 我的应用程序必须支持所有语
下面是一些从仅包含一个文件的 zip 文件中提取文件的代码。但是,提取的文件与通过 WinZip 或其他压缩实用程序提取的同一文件不匹配。如果文件包含奇数个字节,我预计它可能会关闭一个字节(因为我的缓
我正在尝试从 ZIP 存档中读取 XML 文件。相关代码如下: ZipInputStream zis = new ZipInputStream(is); ZipEntry entry = zis.ge
我正在开发一个电子阅读器应用程序(使用 skyepub ),它基本上将加密的书籍下载到文件系统中(并将解密 key 保存在数据库中),当用户尝试阅读它时,它会加载将书存入内存并解密。 问题是有些书的第
我正在尝试从 ZIP 存档中读取 XML 文件。相关代码如下: ZipInputStream zis = new ZipInputStream(is); ZipEntry entry = zis.ge
有java.io.ZipInputStream膨胀和java.io.ZipOutputStream这会泄气。 但有时我不希望这样。有时,当使用接受 InputStream 的第三方 API 时,我想要
我想知道是否有一种方法可以直接从 ZipFile/ZipInputStream 读取特定文件,而不必遍历整个条目集。我想这可能是一个很大的开销,如果存档包含大量文件。有没有更好的办法? 我知道这可以用
因此,在 ZIP 文件的末尾,例如最后 64K,有一个中央目录,从中您可以看到 ZIP 文件本身包含的内容。 现在我已将 ZIP 文件加载到 ZipInputStream 中,在此之前我已声明一个 l
我有一个 JSF 应用程序(Majorra 2.1.20、PrimeFaces 4.0-SNAPSHOT、OmniFaces 1.4.1,在 Glassfish 3.1.2 上运行),可以在 Fire
那么使用ZipInputStream时,要在WEB上获取Zip文件的InputStream,使用时是否会将整个ZIP文件下载到用户计算机中? 例如,如果程序使用 ZipInputStream 来查看
在我们完全读取流之前,是否可以找到/估计 ZipInputStream 的大小? 例如,我们可以在读取用户数据之前使用 getNextEntry 获取条目的元数据。 Inputstream 有一个方法
我可以通过 ZipInputStream,但在开始迭代之前,我想获取迭代期间所需的特定文件。我该怎么做? ZipInputStream zin = new ZipInputStream(myInput
我正在使用 AsyncTask 解压缩文件,一切似乎都进行得很顺利(ZIP 存档中的所有文件都已提取),但我的解压缩方法从未完成。 这是我的解压类的源代码: public class MyUnzipp
假设我们有这样的代码: File file = new File("zip1.zip"); ZipInputStream zis = new ZipInputStream(new FileInputS
我们正在尝试修改 2007 MS Excel 中的 XML 文件之一。为此,将使用 Java 的 ZipInputStream 解压缩 xlsx 文件,然后使用 ZipOutputStream 将其复
我正在尝试从 zip 中解压缩特定文件。我首先得到一个ZipInputStream: ZipInputStream zipIn = new ZipInputStream(new BufferedInp
我做了this问题,我看到存在一个名为 ZipInputStream 的构造函数: ZipInputStream(BufferedInputStream, 字符集) 但是调试器向我抛出错误: ZipI
private byte[] loadClassData(String className) { ZipInputStream in = null; FileInputStream f
我是一名优秀的程序员,十分优秀!