de.schlichtherle.truezip.zip.ZipFile Java Examples
The following examples show how to use
de.schlichtherle.truezip.zip.ZipFile.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShortcutDialog.java From setupmaker with Apache License 2.0 | 5 votes |
private void search(ZipFile zipFile, Stack<File> files) throws IOException, ClassNotFoundException { Enumeration<? extends ZipEntry> entries = zipFile.entries(); while(entries.hasMoreElements()){ ZipEntry entry = entries.nextElement(); files.push(new File(entry.getName())); } }
Example #2
Source File: SessionLoaderImpl2.java From chipster with MIT License | 5 votes |
/** * * The open file and/or stream is stored in field, remember to close them. * * <pre> * try { * * } finally { * IOUtils.closeIfPossible(zipFile); * IOUtils.closeIfPossible(zipStream); * } * </pre> * * @param zipEntry * @return * @throws Exception */ private InputStream getStreamOfZipEntry(String zipEntry) throws Exception { InputStream stream = null; if (sessionFile != null) { if (!sessionFile.exists()) { throw new IOException("session file does not exist: " + sessionFile); } // get the zip entry using TrueZip zipFile = new ZipFile(sessionFile); stream = zipFile.getInputStream(zipEntry); } else if (sessionId != null) { FileBrokerClient fileBrokerClient = Session.getSession().getServiceAccessor().getFileBrokerClient(); InputStream inputStream = fileBrokerClient.getInputStream(sessionId); // get the session.xml zip entry using JDK, we don't need large ZIP support here because URL based sessions have no data zipStream = new ZipInputStream(inputStream); ZipEntry entry; while ((entry = zipStream.getNextEntry()) != null) { if (zipEntry.equals(entry.getName())) { stream = zipStream; // zip stream is wound to right entry now, use it break; } } } return stream; }
Example #3
Source File: ZipUtils.java From chipster with MIT License | 5 votes |
public static void closeIfPossible(ZipFile zipFile) { if (zipFile != null) { try { zipFile.close(); } catch (IOException e) { // ignore } } }
Example #4
Source File: ZipContentHandler.java From chipster with MIT License | 5 votes |
@Override public Long getContentLength(ContentLocation location) throws IOException { checkCompatibility(location); ZipFile zipFile = createZipFile(location); ZipEntry zipEntry = zipFile.getEntry(location.getUrl().getRef()); return zipEntry.getSize(); }
Example #5
Source File: ZipContentHandler.java From chipster with MIT License | 5 votes |
@Override public InputStream getInputStream(ContentLocation location) throws IOException { checkCompatibility(location); ZipFile zipFile = createZipFile(location); ZipEntry zipEntry = zipFile.getEntry(location.getUrl().getRef()); return zipFile.getInputStream(zipEntry); }
Example #6
Source File: ZipContentHandler.java From chipster with MIT License | 5 votes |
/** * Pools ZipFile instances to avoid having too many files open. * */ private ZipFile createZipFile(ContentLocation location) throws IOException { File file = getZipFile(location); if (!zipFileInstances.containsKey(file)) { zipFileInstances.put(file, new ZipFile(file)); } return zipFileInstances.get(file); }
Example #7
Source File: ZipContentHandler.java From chipster with MIT License | 5 votes |
public void closeZipFiles() { // Try to close all zip files for (ZipFile zipFile : zipFileInstances.values()) { try { zipFile.close(); } catch (Exception e) { logger.warn("could not close zip file"); } } // Clear instance pool so that they are created again when needed next time zipFileInstances.clear(); }
Example #8
Source File: ZipContentHandler.java From chipster with MIT License | 5 votes |
@Override public boolean isAccessible(ContentLocation location) { checkCompatibility(location); try { ZipFile zipFile = createZipFile(location); return zipFile.getEntry(location.getUrl().getRef()) != null; } catch (IOException e) { return false; } }
Example #9
Source File: TZipOutputStream.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 4 votes |
public TZipOutputStream(OutputStream out, ZipFile appendee) { super(out, appendee); }