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 FileLoader extends ResourceLoader implements java.io.Serializable { 39 40 public URL getURL(String location) throws GenericConfigException { 41 String fullLocation = fullLocation(location); 42 URL fileUrl = null; 43 44 fileUrl = UtilURL.fromFilename(fullLocation); 45 if (fileUrl == null) { 46 throw new GenericConfigException("File Resource not found: " + fullLocation); 47 } 48 return fileUrl; 49 } 50 51 public InputStream loadResource(String location) throws GenericConfigException { 52 URL fileUrl = getURL(location); 53 try { 54 return fileUrl.openStream(); 55 } catch (java.io.IOException e) { 56 throw new GenericConfigException("Error opening file at location [" + fileUrl.toExternalForm() + "]", e); 57 } 58 } 59 } 60 | Popular Tags |