Reads the given entry from the zip. @param input a zip file @param toRead a path within that zip file @param reader will be called with an InputStream containing the contents of that entry in the zip file
(File input, String toRead, Throwing.Specific.Consumer<InputStream, IOException> reader)
| 54 | * @param reader will be called with an InputStream containing the contents of that entry in the zip file |
| 55 | */ |
| 56 | public static void read(File input, String toRead, Throwing.Specific.Consumer<InputStream, IOException> reader) throws IOException { |
| 57 | try ( |
| 58 | ZipFile file = new ZipFile(input); |
| 59 | InputStream stream = file.getInputStream(file.getEntry(toRead));) { |
| 60 | reader.accept(stream); |
| 61 | } catch (NullPointerException e) { |
| 62 | if (e.getMessage().equals("entry")) { |
| 63 | System.err.println("No such entry: " + toRead); |
| 64 | try (ZipFile file = new ZipFile(input)) { |
| 65 | Enumeration<? extends ZipEntry> entries = file.entries(); |
| 66 | while (entries.hasMoreElements()) { |
| 67 | ZipEntry entry = entries.nextElement(); |
| 68 | System.err.println(" available: " + entry.getName()); |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Reads the given entry from the zip. |