MCPcopy Index your code
hub / github.com/VolmitSoftware/Adapt / readEntry

Method readEntry

src/main/java/com/volmit/adapt/util/IO.java:298–321  ·  view source on GitHub ↗
(File zipfile, String entryname, Consumer<InputStream> v)

Source from the content-addressed store, hash-verified

296 }
297
298 public static void readEntry(File zipfile, String entryname, Consumer<InputStream> v) throws IOException {
299 ZipFile file = new ZipFile(zipfile);
300 Throwable x = null;
301
302 try {
303 Enumeration<? extends ZipEntry> entries = file.entries();
304 while (entries.hasMoreElements()) {
305 ZipEntry entry = entries.nextElement();
306
307 if (entryname.equals(entry.getName())) {
308 InputStream in = file.getInputStream(entry);
309 v.accept(in);
310 }
311 }
312 } catch (Exception ex) {
313 x = ex.getCause();
314 } finally {
315 file.close();
316 }
317
318 if (x != null) {
319 throw new IOException("Failed to read zip entry, however it has been closed safely.", x);
320 }
321 }
322
323 public static void writeAll(File f, Object c) throws IOException {
324 f.getParentFile().mkdirs();

Callers

nothing calls this directly

Calls 5

getCauseMethod · 0.80
getNameMethod · 0.65
acceptMethod · 0.65
closeMethod · 0.65
equalsMethod · 0.45

Tested by

no test coverage detected