1 package org.lcsim.conditions.readers; 2 3 import java.io.File; 4 import java.io.IOException; 5 import java.io.InputStream; 6 import java.util.zip.ZipEntry; 7 import java.util.zip.ZipFile; 8 9 import org.lcsim.conditions.ConditionsReader; 10 11 public class ZipConditionsReader extends ConditionsReader { 12 13 private ZipFile zip; 14 15 public ZipConditionsReader(File file) throws IOException { 16 this.zip = new ZipFile(file, ZipFile.OPEN_READ); 17 } 18 19 public InputStream open(String name, String type) throws IOException { 20 ZipEntry entry = zip.getEntry(name + "." + type); 21 if (entry == null) { 22 throw new IOException("Conditions " + name + "." + type + " not found"); 23 } 24 return zip.getInputStream(entry); 25 } 26 27 public void close() throws IOException { 28 zip.close(); 29 } 30 }