private void readAllHeaders() throws IOException { if (myAllFilesAreRead) { return; } myAllFilesAreRead = true; MyBufferedInputStream baseStream = getBaseStream(); baseStream.setPosition(0); myFileHeaders.clear(); try { while (baseStream.available() > 0) { readFileHeader(baseStream, null); } } finally { storeBaseStream(baseStream); } }
public LocalFileHeader getHeader(String entryName) throws IOException { if (!myFileHeaders.isEmpty()) { LocalFileHeader header = myFileHeaders.get(entryName); if (header != null) { return header; } if (myAllFilesAreRead) { throw new ZipException("Entry " + entryName + " is not found"); } } // ready to read file header MyBufferedInputStream baseStream = getBaseStream(); baseStream.setPosition(0); try { while (baseStream.available() > 0 && !readFileHeader(baseStream, entryName)) {} final LocalFileHeader header = myFileHeaders.get(entryName); if (header != null) { return header; } } finally { storeBaseStream(baseStream); } throw new ZipException("Entry " + entryName + " is not found"); }