List of usage examples for org.apache.commons.collections ExtendedProperties load
public void load(InputStream input) throws IOException
From source file:org.opencms.util.CmsPropertyUtils.java
/** * Loads an extended property file and performs unescaping of "," and "=" entries.<p> * // w ww. j a v a 2s .c o m * @param file the file to read the properties from * * @return the initialized extended properties * * @throws IOException in case of IO errors */ public static ExtendedProperties loadProperties(String file) throws IOException { FileInputStream input = null; ExtendedProperties properties = null; try { input = new FileInputStream(new File(file)); properties = new ExtendedProperties(); properties.load(input); input.close(); } catch (IOException e) { try { if (input != null) { input.close(); } } catch (Exception ex) { // nothing we can do } throw e; } unescapeProperties(properties); return properties; }
From source file:org.sakaiproject.vm.VelocityServlet.java
/** * Called by the VelocityServlet init(). We want to set a set of properties so that templates will be found in the webapp root. This makes this easier to work with as an example, so a new user doesn't have to worry about config issues when first * figuring things out/*from ww w.ja v a2s. c o m*/ */ protected ExtendedProperties loadConfiguration(ServletConfig config) throws IOException, FileNotFoundException { // This is to support old config property. String configPath = config.getInitParameter("properties"); ExtendedProperties p; if (configPath != null && configPath.length() > 0) { p = new ExtendedProperties(); if (!configPath.startsWith("/")) { configPath = "/" + configPath; } p.load(getServletContext().getResourceAsStream(configPath)); } else { // load the properties as configured in the servlet init params p = super.loadConfiguration(config); } /* * first, we set the template path for the FileResourceLoader to the root of the webapp. This probably won't work under in a WAR under WebLogic, but should under tomcat :) */ String path = config.getServletContext().getRealPath("/"); if (path == null) { getVelocityEngine().getLog().debug(" VelocityServlet.loadConfiguration() : unable to " + "get the current webapp root. Using '/'. Please fix."); path = "/"; } p.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path); /** * and the same for the log file */ p.setProperty("runtime.log", path + p.getProperty("runtime.log")); return p; }
From source file:paremus.PSFDeployRunWarMojo.java
public PSFDeployRunWarMojo() { final ExtendedProperties extendedProperties = new ExtendedProperties(); try {/* w w w . java 2 s. c om*/ extendedProperties.load(AbstractPSFMojo.class.getResourceAsStream("/psf-velocity.properties")); } catch (IOException e) { e.printStackTrace(); } velocity = new VelocityEngine(); velocity.setExtendedProperties(extendedProperties); velocity.init(); }