1 25 package org.ofbiz.base.config; 26 27 import java.net.*; 28 import java.io.*; 29 import org.ofbiz.base.util.*; 30 31 38 public class ClasspathLoader extends ResourceLoader implements java.io.Serializable { 39 40 public URL getURL(String location) throws GenericConfigException { 41 String fullLocation = fullLocation(location); 42 URL url = UtilURL.fromResource(fullLocation); 43 if (url == null) { 44 throw new GenericConfigException("Classpath Resource not found: " + fullLocation); 45 } 46 return url; 47 } 48 49 public InputStream loadResource(String location) throws GenericConfigException { 50 URL url = getURL(location); 51 try { 52 return url.openStream(); 53 } catch (java.io.IOException e) { 54 throw new GenericConfigException("Error opening classpath resource at location [" + url.toExternalForm() + "]", e); 55 } 56 } 57 } 58 | Popular Tags |