Your current approach will definitely not work. You created an arbitrary access scheme and used it in a class that has no idea what you are trying to do. What you can use ZipInputStream to read the record you are looking for:
URL zipFileURL = Thread.currentThread().getContextClassLoader().getResource("zipfile.zip"); InputStream inputStream = zipFileURL.openStream(); ZipInputStream zipInputStream = new ZipInputStream(inputStream); ZipEntry zipEntry = null; do { zipEntry = zipInputStream.getNextEntry(); if(zipEntry == null) break; } while(zipEntry != null && (! "textfile".equals(zipEntry.getName())); if(zipEntry != null ) {
This is adhoc code, correct it to do what you need. In addition, there may be some more efficient classes for processing Zip files, for example, in the IO Apache Commons library.
source share