1 package org.lcsim.conditions.readers; 2 3 import java.io.BufferedInputStream; 4 import java.io.File; 5 import java.io.FileInputStream; 6 import java.io.IOException; 7 import java.io.InputStream; 8 9 import org.lcsim.conditions.ConditionsReader; 10 11 public class DirectoryConditionsReader extends ConditionsReader { 12 13 private File dir; 14 15 public DirectoryConditionsReader(File file) throws IOException { 16 this.dir = file; 17 } 18 19 public InputStream open(String name, String type) throws IOException { 20 File file = new File(dir, name + "." + type); 21 if (!file.exists()) { 22 throw new IOException("Conditions " + name + "." + type + " not found, because directory " + file.getAbsolutePath() + " does not exist."); 23 } 24 return new BufferedInputStream(new FileInputStream(file)); 25 } 26 27 public void close() throws IOException { 28 } 29 }