gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-18 01:26:40 24 4
gpt4 key购买 nike

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

ZipInputStream.available介绍

[英]Returns 0 after EOF has reached for the current entry data, otherwise always return 1.

Programs should not count on this method to return the actual number of bytes that could be read without blocking.
[中]在EOF达到当前条目数据后返回0,否则始终返回1。
程序不应依赖此方法返回可以在不阻塞的情况下读取的实际字节数。

代码示例

代码示例来源:origin: stackoverflow.com

import java.io.FileInputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class Main {
  public static void main(String[] args) throws Exception
  {
    FileInputStream fis = new FileInputStream("c:/inas400.zip");

    // this is where you start, with an InputStream containing the bytes from the zip file
    ZipInputStream zis = new ZipInputStream(fis);
    ZipEntry entry;
      // while there are entries I process them
    while ((entry = zis.getNextEntry()) != null)
    {
      System.out.println("entry: " + entry.getName() + ", " + entry.getSize());
          // consume all the data from this entry
      while (zis.available() > 0)
        zis.read();
          // I could close the entry, but getNextEntry does it automatically
          // zis.closeEntry()
    }
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@SuppressWarnings("unchecked")
public <T> T readObject(ByteBuffer data, Class<T> c) throws IOException {
  try
  {
    ZIPCompressedMessage result = new ZIPCompressedMessage();
    byte[] byteArray = new byte[data.remaining()];
    data.get(byteArray);
    ZipInputStream in = new ZipInputStream(new ByteArrayInputStream(byteArray));
    in.getNextEntry();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    byte[] tmp = new byte[9012];
    int read;
    while (in.available() > 0 && ((read = in.read(tmp)) > 0)) {
      out.write(tmp, 0, read);
    }
    in.closeEntry();
    out.flush();
    in.close();
    result.setMessage((Message)Serializer.readClassAndObject(ByteBuffer.wrap(out.toByteArray())));
    return (T)result;
  }
  catch (Exception e) {
    e.printStackTrace();
    throw new IOException(e.toString());
  }
}

代码示例来源:origin: org.openl.rules/org.openl.rules.ruleservice.deployer

@Override
public int available() throws IOException {
  return source.available();
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-j2ee-jboss4

@Override
public int available() throws IOException {
  return zis.available();
}

代码示例来源:origin: asakusafw/asakusafw

@Override
public int available() throws IOException {
  return zipped.available();
}

代码示例来源:origin: asakusafw/asakusafw

@Override
public int available() throws IOException {
  return zipped.available();
}

代码示例来源:origin: org.apache.openejb.patch/openjpa

public int available() throws IOException {
  return _stream.available();
}

代码示例来源:origin: openl-tablets/openl-tablets

@Override
public int available() throws IOException {
  return source.available();
}

代码示例来源:origin: org.apache.openjpa/com.springsource.org.apache.openjpa

public int available() throws IOException {
  return _stream.available();
}

代码示例来源:origin: org.apache.openjpa/openjpa-all

public int available() throws IOException {
  return _stream.available();
}

代码示例来源:origin: org.apache.openjpa/openjpa-lib

public int available() throws IOException {
  return _stream.available();
}

代码示例来源:origin: org.nuxeo.common/nuxeo-common

public static List<String> getEntryNames(InputStream stream) throws IOException {
  List<String> result = new ArrayList<>();
  try (ZipInputStream zip = new ZipInputStream(stream)) {
    while (zip.available() == 1) {
      ZipEntry entry = zip.getNextEntry();
      if (entry != null) {
        result.add(entry.getName());
      }
    }
  }
  return result;
}

代码示例来源:origin: org.wso2.carbon/org.wso2.carbon.bridge

/**
 * @param zipInputStream zipInputStream
 * @return return zipetry map
 * @throws IOException IOException
 */
private static List<ZipEntry> populateList(ZipInputStream zipInputStream) throws IOException {
  List<ZipEntry> listEntry = new ArrayList<ZipEntry>();
  while (zipInputStream.available() == 1) {
    ZipEntry entry = zipInputStream.getNextEntry();
    if (entry == null) {
      break;
    }
    listEntry.add(entry);
  }
  return listEntry;
}

代码示例来源:origin: stackoverflow.com

ZipInputStream zip = null;
 try {
   zip = new ZipInputStream(url.openStream());
   ZipEntry entry;
   do{
     entry = zip.getNextEntry();
   } while(!yourExpectedFileName.equals(entry.getName())
   while(zip.available()){
      //read your data
   }
   zip.closeEntry();
 } finally {
   if (zip != null)
     zip.close();
 }

代码示例来源:origin: Talend/components

private void writeZipIntoFile(ZipInputStream zipInputStream, File file) throws IOException {
  BufferedWriter configOutput = null;
  try {
    int read;
    configOutput = new BufferedWriter(new FileWriter(file));
    while (zipInputStream.available() > 0) {
      if ((read = zipInputStream.read()) != -1) {
        configOutput.write(read);
      }
    }
  } finally {
    if (configOutput != null) {
      configOutput.close();
    }
  }
}

代码示例来源:origin: beanshell/beanshell

/** Search Archive for classes.
 * @param the archive file location
 * @return array of class names found
 * @throws IOException */
static String [] searchArchiveForClasses( URL url ) throws IOException {
  List<String> list = new ArrayList<>();
  ZipInputStream zip = new ZipInputStream(url.openStream());
  ZipEntry ze;
  while( zip.available() == 1 )
    if ( (ze = zip.getNextEntry()) != null
        && isClassFileName( ze.getName() ) )
      list.add( canonicalizeClassName( ze.getName() ) );
  zip.close();
  return list.toArray( new String[list.size()] );
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.emf.ecore

/**
 * Returns the input stream for the zip entry, or the original input stream, as appropriate.
 */
private InputStream getUnderlyingInputStream(InputStream inputStream, Map<?, ?> options) throws IOException
{
 if (useZip() || (options != null && Boolean.TRUE.equals(options.get(Resource.OPTION_ZIP))))
 {
  ZipInputStream zipInputStream = new ZipInputStream(inputStream);
  while (zipInputStream.available() != 0)
  {
   ZipEntry zipEntry = zipInputStream.getNextEntry();
   if (isContentZipEntry(zipEntry))
   {
    return zipInputStream;
   }
  }
 }
 return inputStream;
}

代码示例来源:origin: org.eclipse.emf/org.eclipse.emf.ecore

/**
 * Returns the input stream for the zip entry, or the original input stream, as appropriate.
 */
private InputStream getUnderlyingInputStream(InputStream inputStream, Map<?, ?> options) throws IOException
{
 if (useZip() || (options != null && Boolean.TRUE.equals(options.get(Resource.OPTION_ZIP))))
 {
  ZipInputStream zipInputStream = new ZipInputStream(inputStream);
  while (zipInputStream.available() != 0)
  {
   ZipEntry zipEntry = zipInputStream.getNextEntry();
   if (isContentZipEntry(zipEntry))
   {
    return zipInputStream;
   }
  }
 }
 return inputStream;
}

代码示例来源:origin: de.fosd.typechef/javabdd_repackaged

public static void loadAndAnalyzeZip(String filename) throws Exception {
  InputStream  is = new FileInputStream (filename);
  ZipInputStream zis = new ZipInputStream(is);
  AutomataAnalyzerData.printHeader();
  ZipEntry ze = zis.getNextEntry();
  while(zis.available()!= 0) {
    if(!ze.isDirectory() ) {
      Automata a = AutomataIO.loadXML(zis);
      if(a != null) {
        AutomataAnalyzerData dat = analyze(a, ze.getName() );
        dat.print();
      }
    }
    zis.closeEntry();
    ze = zis.getNextEntry();
  }
  zis.close();
  is.close();
}

代码示例来源:origin: freeplane/freeplane

private void importMindmanagerFile(final File file) {
  ZipInputStream in = null;
  try {
    in = new ZipInputStream(new FileInputStream(file));
    while (in.available() != 0) {
      final ZipEntry entry = in.getNextEntry();
      if (entry == null) {
        break;
      }
      if (!entry.getName().equals("Document.xml")) {
        continue;
      }
      final String xsltFileName = "/xslt/mindmanager2mm.xsl";
      final File outputFile = new File (file.getParent(), file.getName() + org.freeplane.features.url.UrlManager.FREEPLANE_FILE_EXTENSION);
      new XmlImporter(xsltFileName).importXml(in, outputFile);
      break;
    }
  }
  catch (final Exception e) {
    LogUtils.severe(e);
  }
  finally {
    FileUtils.silentlyClose(in);
  }
}

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