There are 7 code examples for java.util.zip.ZipEntry.

The API names are highlighted below. You can use suckoo button to vote the code example(s) you like. The best code example will be ranked first next time. Thanks a lot for your feedback.

Project Name: icTAKES Package: edu.mayo.bmi.nlp.parser.ae

Source Code: ClearParserUtil.java (Click to view .java file)

Method Code:
vote
like

public static AbstractSRLParser createSRLParser(InputStream inputStream) throws IOException {
  final String s_language=AbstractReader.LANG_EN;
  ZipInputStream zin=new ZipInputStream(inputStream);
  ZipEntry zEntry;
  String entry;
  SRLFtrXml xml=null;
  SRLFtrMap[] map=new SRLFtrMap[2];
  OneVsAllDecoder[] decoder=new OneVsAllDecoder[2];
  while ((zEntry=zin.getNextEntry()) != null) {
    if (zEntry.getName().equals(ENTRY_FEATURE)) {
      BufferedReader reader=new BufferedReader(new InputStreamReader(zin));
      StringBuilder build=new StringBuilder();
      String string;
      while ((string=reader.readLine()) != null) {
        build.append(string);
        build.append("\n");
      }
      xml=new SRLFtrXml(new ByteArrayInputStream(build.toString().getBytes()));
    }
 else     if ((entry=zEntry.getName()).startsWith(ENTRY_LEXICA)) {
      int i=Integer.parseInt(entry.substring(entry.lastIndexOf(".") + 1));
      map[i]=new SRLFtrMap(new BufferedReader(new InputStreamReader(zin)));
    }
 else     if (zEntry.getName().startsWith(ENTRY_MODEL)) {
      int i=Integer.parseInt(entry.substring(entry.lastIndexOf(".") + 1));
      decoder[i]=new OneVsAllDecoder(new BufferedReader(new InputStreamReader(zin)));
    }
  }
  AbstractSRLParser labeler=new SRLParser(AbstractParser.FLAG_PREDICT,xml,map,decoder);
  labeler.setLanguage(s_language);
  return labeler;
}
 

Project Name: megamek Package: megamek.client.ui.AWT.util

Source Code: ImageFileFactory.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Get the <code>ItemFile</code> for the given <code>ZipEntry</code> in
 * the <code>ZipFile</code>.
 * @param zipEntry - the <code>ZipEntry</code> that will be read to
 * produce the item. This value must not be <code>null</code>.
 * @param zipFile - the <code>ZipFile</code> object that contains the
 * <code>ZipEntry</code> that will produce the item. This value
 * must not be <code>null</code>.
 * @return an <code>ItemFile</code> for the given zip file entry.
 * @throws <code>IllegalArgumentException</code> if either the
 * <code>zipEntry</code> or the <code>zipFile</code> is
 * <code>null</code>.
 */
public ItemFile getItemFile(final ZipEntry zipEntry,final ZipFile zipFile) throws IllegalArgumentException {
  if (null == zipEntry) {
    throw new IllegalArgumentException("A null ZIP entry was passed.");
  }
  if (null == zipFile) {
    throw new IllegalArgumentException("A null ZIP file was passed.");
  }
  return new ItemFile(){
    private ZipEntry itemEntry=zipEntry;
    private Image image=null;
    public Object getItem() throws Exception {
      if (null == image) {
        InputStream in=new BufferedInputStream(zipFile.getInputStream(itemEntry),(int)itemEntry.getSize());
        byte[] buffer=new byte[(int)itemEntry.getSize()];
        in.read(buffer);
        int index=(int)itemEntry.getSize() - 10;
        while (itemEntry.getSize() > index) {
          if (0 != buffer[index]) {
            break;
          }
          index++;
        }
        if (itemEntry.getSize() <= index) {
          throw new IOException("Error reading " + itemEntry.getName() + "\nYou may want to unzip "+ zipFile.getName());
        }
        image=Toolkit.getDefaultToolkit().createImage(buffer);
      }
      return image.getScaledInstance(84,72,Image.SCALE_FAST);
    }
  }
;
}
 

Project Name: megamek Package: megamek.client.ui.AWT.util

Source Code: ImageFileFactory.java (Click to view .java file)

Method Code:
vote
like

public Object getItem() throws Exception {
  if (null == image) {
    InputStream in=new BufferedInputStream(zipFile.getInputStream(itemEntry),(int)itemEntry.getSize());
    byte[] buffer=new byte[(int)itemEntry.getSize()];
    in.read(buffer);
    int index=(int)itemEntry.getSize() - 10;
    while (itemEntry.getSize() > index) {
      if (0 != buffer[index]) {
        break;
      }
      index++;
    }
    if (itemEntry.getSize() <= index) {
      throw new IOException("Error reading " + itemEntry.getName() + "\nYou may want to unzip "+ zipFile.getName());
    }
    image=Toolkit.getDefaultToolkit().createImage(buffer);
  }
  return image.getScaledInstance(84,72,Image.SCALE_FAST);
}
 

Project Name: megamek Package: megamek.client.ui.swing.util

Source Code: ImageFileFactory.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Get the <code>ItemFile</code> for the given <code>ZipEntry</code> in
 * the <code>ZipFile</code>.
 * @param zipEntry - the <code>ZipEntry</code> that will be read to
 * produce the item. This value must not be <code>null</code>.
 * @param zipFile - the <code>ZipFile</code> object that contains the
 * <code>ZipEntry</code> that will produce the item. This value
 * must not be <code>null</code>.
 * @return an <code>ItemFile</code> for the given zip file entry.
 * @throws <code>IllegalArgumentException</code> if either the
 * <code>zipEntry</code> or the <code>zipFile</code> is
 * <code>null</code>.
 */
public ItemFile getItemFile(final ZipEntry zipEntry,final ZipFile zipFile) throws IllegalArgumentException {
  if (null == zipEntry) {
    throw new IllegalArgumentException("A null ZIP entry was passed.");
  }
  if (null == zipFile) {
    throw new IllegalArgumentException("A null ZIP file was passed.");
  }
  return new ItemFile(){
    private ZipEntry itemEntry=zipEntry;
    private Image image=null;
    public Object getItem() throws Exception {
      if (null == image) {
        InputStream in=new BufferedInputStream(zipFile.getInputStream(itemEntry),(int)itemEntry.getSize());
        byte[] buffer=new byte[(int)itemEntry.getSize()];
        in.read(buffer);
        int index=(int)itemEntry.getSize() - 10;
        while (itemEntry.getSize() > index) {
          if (0 != buffer[index]) {
            break;
          }
          index++;
        }
        if (itemEntry.getSize() <= index) {
          throw new IOException("Error reading " + itemEntry.getName() + "\nYou may want to unzip "+ zipFile.getName());
        }
        image=Toolkit.getDefaultToolkit().createImage(buffer);
      }
      return image.getScaledInstance(84,72,Image.SCALE_FAST);
    }
  }
;
}
 

Project Name: megamek Package: megamek.client.ui.swing.util

Source Code: ImageFileFactory.java (Click to view .java file)

Method Code:
vote
like

public Object getItem() throws Exception {
  if (null == image) {
    InputStream in=new BufferedInputStream(zipFile.getInputStream(itemEntry),(int)itemEntry.getSize());
    byte[] buffer=new byte[(int)itemEntry.getSize()];
    in.read(buffer);
    int index=(int)itemEntry.getSize() - 10;
    while (itemEntry.getSize() > index) {
      if (0 != buffer[index]) {
        break;
      }
      index++;
    }
    if (itemEntry.getSize() <= index) {
      throw new IOException("Error reading " + itemEntry.getName() + "\nYou may want to unzip "+ zipFile.getName());
    }
    image=Toolkit.getDefaultToolkit().createImage(buffer);
  }
  return image.getScaledInstance(84,72,Image.SCALE_FAST);
}
 

Project Name: weka Package: weka.core

Source Code: WekaPackageManager.java (Click to view .java file)

Method Code:
vote
like

public static Exception refreshCache(PrintStream... progress){
  Exception problem=null;
  if (CACHE_URL == null) {
    return null;
  }
  PACKAGE_MANAGER.setPackageRepositoryURL(REP_URL);
  String cacheDir=WEKA_HOME.toString() + File.separator + "repCache";
  try {
    for (    PrintStream p : progress) {
      p.println("Refresh in progress. Please wait...");
    }
    byte[] zip=PACKAGE_MANAGER.getRepositoryPackageMetaDataOnlyAsZip(progress);
    ZipInputStream zis=new ZipInputStream(new ByteArrayInputStream(zip));
    ZipEntry ze;
    final byte[] buff=new byte[1024];
    while ((ze=zis.getNextEntry()) != null) {
      if (ze.isDirectory()) {
        new File(cacheDir,ze.getName()).mkdir();
        continue;
      }
      BufferedOutputStream bo=new BufferedOutputStream(new FileOutputStream(new File(cacheDir,ze.getName())));
      while (true) {
        int amountRead=zis.read(buff);
        if (amountRead == -1) {
          break;
        }
        bo.write(buff,0,amountRead);
      }
      bo.close();
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
    CACHE_URL=null;
    try {
      DefaultPackageManager.deleteDir(new File(cacheDir),System.out);
    }
 catch (    Exception e1) {
      e1.printStackTrace();
    }
    return e;
  }
  return problem;
}
 

Project Name: weka Package: weka.experiment

Source Code: OutputZipper.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Saves a string to either an individual gzipped file or as
 * an entry in a zip file.
 * @param outString the output string to save
 * @param name the name of the file/entry to save it to
 * @throws Exception if something goes wrong
 */
public void zipit(String outString,String name) throws Exception {
  File saveFile;
  ZipEntry ze;
  if (m_zipOut == null) {
    saveFile=new File(m_destination,name + ".gz");
    DataOutputStream dout=new DataOutputStream(new GZIPOutputStream(new FileOutputStream(saveFile)));
    dout.writeBytes(outString);
    dout.close();
  }
 else {
    ze=new ZipEntry(name);
    m_zs.putNextEntry(ze);
    m_zipOut.writeBytes(outString);
    m_zs.closeEntry();
  }
}