gpt4 book ai didi

java.util.zip.ZipInputStream.getNextEntry()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 00:42:40 27 4
gpt4 key购买 nike

本文整理了Java中java.util.zip.ZipInputStream.getNextEntry()方法的一些代码示例,展示了ZipInputStream.getNextEntry()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipInputStream.getNextEntry()方法的具体详情如下:
包路径:java.util.zip.ZipInputStream
类名称:ZipInputStream
方法名:getNextEntry

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();
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com