1 41 package org.jfree.base.config; 42 43 import java.io.BufferedInputStream ; 44 import java.io.IOException ; 45 import java.io.InputStream ; 46 import java.util.Properties ; 47 48 import org.jfree.util.Log; 49 import org.jfree.util.ObjectUtilities; 50 51 56 public class PropertyFileConfiguration extends HierarchicalConfiguration 57 { 58 65 public void load(final String resourceName) 66 { 67 final InputStream in = ObjectUtilities.getResourceRelativeAsStream 68 (resourceName, PropertyFileConfiguration.class); 69 if (in != null) 70 { 71 load(in); 72 } 73 else 74 { 75 Log.debug ("Configuration file not found in the classpath: " + resourceName); 76 } 77 78 } 79 80 87 public void load(final InputStream in) 88 { 89 if (in == null) 90 { 91 throw new NullPointerException (); 92 } 93 94 try 95 { 96 final BufferedInputStream bin = new BufferedInputStream (in); 97 final Properties p = new Properties (); 98 p.load(bin); 99 this.getConfiguration().putAll(p); 100 bin.close(); 101 } 102 catch (IOException ioe) 103 { 104 Log.warn("Unable to read configuration", ioe); 105 } 106 107 } 108 109 112 public PropertyFileConfiguration() { 113 } 115 } 116 | Popular Tags |