/**
* Unzip directly the entry. The returned InputStream has to be closed.
* @return the input stream of the desired entry - has to be closed by thecaller, or null if not found
* @param file the source file
* @param entryName the entry name that has to be extracted
*/
public static InputStream getEntryContentAsStream(File file,String entryName) throws IOException {
InputStream result=null;
ZipFile zip=new ZipFile(file);
ZipEntry entry=zip.getEntry(entryName);
if (entry != null) {
result=zip.getInputStream(entry);
}
return result;
}

Example 17

From project nuxeo-jsf, under directory /nuxeo-platform-webapp-base/src/test/java/org/nuxeo/ecm/webapp/clipboard/.

/**
* Unzip directly the entry. The returned InputStream has to be closed.
* @return the input stream of the desired entry - has to be closed by thecaller, or null if not found
* @param file the source file
* @param entryName the entry name that has to be extracted
*/
public static InputStream getEntryContentAsStream(File file,String entryName) throws IOException {
InputStream result=null;
ZipFile zip=new ZipFile(file);
ZipEntry entry=zip.getEntry(entryName);
if (entry != null) {
result=zip.getInputStream(entry);
}
return result;
}

Example 20

From project onebusaway-nyc, under directory /onebusaway-nyc-transit-data-manager/onebusaway-nyc-tdm-webapp/src/test/java/org/onebusaway/nyc/transit_data_manager/api/barcode/.

/**
* This method gets called if we are dealing with an actual archive and not an exploded archive. This archive is exploded to a temporary directory so that it can be altered in the same manner as if we were dealing with an expldoded archive.
*/
private void JSFUnitWar(){
try {
File tmpDir=File.createTempFile("jsfunitwartask","");
tmpDir.delete();
tmpDir.mkdir();
ZipFile zip=new ZipFile(srcfile);
File explodedArchive=Utils.explodeArchive(zip,tmpDir);
WebXml webXml=getWebXml(explodedArchive);
editWebXml(webXml);
writeWebXml(explodedArchive,webXml);
addLibs(explodedArchive);
autoAddLibs(explodedArchive);
addClasses(explodedArchive);
Utils.archive(explodedArchive,destfile);
}
catch ( Exception e) {
log(e.getMessage(),Project.MSG_ERR);
e.printStackTrace();
}
}

Example 68

From project jsword, under directory /src/main/java/org/crosswire/common/util/.