List of usage examples for java.util Properties Properties
public Properties()
From source file:com.hzc.framework.util.PropertiesUtil.java
public static void initExtiact(String extiactConfigPath) { Properties p1 = new Properties(); InputStream is = null;/* w w w .j a va 2 s.c om*/ try { is = new FileInputStream(new File(extiactConfigPath)); p1.load(is); p.putAll(p1); } catch (IOException ex) { log.error(ex); } finally { if (is != null) { try { is.close(); } catch (IOException ex) { log.error(ex); } is = null; } } }
From source file:com.egt.core.util.VelocityEngineer.java
private static Properties getProperties(String propsFilename) throws Exception { Bitacora.trace(VelocityEngineer.class, "getProperties", propsFilename); Properties p = new Properties(); try (FileInputStream inStream = new FileInputStream(propsFilename)) { p.load(inStream);//from w w w .j a v a 2 s . c o m } String comma = System.getProperties().getProperty("path.separator"); String slash = System.getProperties().getProperty("file.separator"); String VFRLP = "$" + EAC.VELOCITY_FILE_RESOURCE_LOADER_PATH; String vfrlp = EA.getString(EAC.VELOCITY_FILE_RESOURCE_LOADER_PATH); vfrlp = vfrlp.replace(comma, ", "); vfrlp = vfrlp.replace(slash, "/"); String key; String value; for (Enumeration e = p.propertyNames(); e.hasMoreElements();) { key = (String) e.nextElement(); value = p.getProperty(key); if (StringUtils.isNotBlank(value) && value.contains(VFRLP)) { value = value.replace(VFRLP, vfrlp); p.setProperty(key, value); } Bitacora.trace(key + "=" + value); } return p; }
From source file:com.silverpeas.util.template.SilverpeasTemplateFactory.java
public static SilverpeasTemplate createSilverpeasTemplateOnComponents(final String pathSuffix) { final Properties config = new Properties(); config.setProperty(SilverpeasTemplate.TEMPLATE_ROOT_DIR, computePath(SilverpeasStringTemplateUtil.defaultComponentsDir, pathSuffix)); config.setProperty(SilverpeasTemplate.TEMPLATE_CUSTOM_DIR, computePath(SilverpeasStringTemplateUtil.customComponentsDir, pathSuffix)); return createSilverpeasTemplate(config); }
From source file:PrintTestApp.java
public PrintTestApp() { super("PrintTestApp"); toolkit = getToolkit();/*from www. j ava 2s . c o m*/ add("Center", textArea); setSize(300, 300); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); String name = "Test print job"; Properties properties = new Properties(); PrintJob pj = toolkit.getPrintJob(PrintTestApp.this, name, properties); if (pj == null) textArea.setText("A null PrintJob was returned."); else { String output = "Name: " + name + "\nProperties: " + properties.toString(); Dimension pageDim = pj.getPageDimension(); int resolution = pj.getPageResolution(); boolean lastPageFirst = pj.lastPageFirst(); output += "\nPage dimension (in pixels):"; output += "\n height: " + String.valueOf(pageDim.height); output += "\n width: " + String.valueOf(pageDim.width); output += "\nResolution (pixels/inch): " + String.valueOf(resolution); output += "\nLast Page First: " + String.valueOf(lastPageFirst); textArea.setText(output); Graphics g = pj.getGraphics(); g.dispose(); pj.end(); } }
From source file:edu.pitt.dbmi.ipm.service.EnterpriseAnalytics.java
/** * Initializes parameters from *.conf file based on selected storage * parameter 'useVitOrPostgre' in jQueryPostgres.conf file *//* w ww .j ava 2 s . c o m*/ private static void initParams() { if (!hasParams) { hasParams = true; try { StorageFactory.getStorage().initParameters(); hasParams = true; Properties params = new Properties(); params.load(new FileInputStream(System.getProperty("user.dir") + File.separator + "resources" + File.separator + StorageFactory.getStorage().getConfFileName())); String prefix_name = params.getProperty("prefix_name"); String prefix = params.getProperty("prefix"); count_patients_by_tss_Q = DataSelection .queryInitReplace(params.getProperty("count_patients_by_tss"), prefix_name, prefix); } catch (Exception ex) { System.out.println(ex.getMessage()); } } }
From source file:com.diffplug.gradle.ConfigMisc.java
/** Creates an XML string from a groovy.util.Node. */ public static byte[] props(Map<String, String> map) { Properties properties = new Properties(); map.forEach((key, value) -> properties.put(key, value)); try (ByteArrayOutputStream output = new ByteArrayOutputStream()) { Errors.rethrow().run(() -> properties.store(output, "")); return output.toByteArray(); } catch (IOException e) { throw Errors.asRuntime(e); }/* www.j a va 2 s.c om*/ }
From source file:com.netflix.iep.config.TestResourceConfiguration.java
public static void load(String propFile, Map<String, String> subs, Map<String, String> overrides) throws IOException { URL propUrl = Resources.getResource(propFile); String propData = Resources.toString(propUrl, Charsets.UTF_8); for (Map.Entry e : subs.entrySet()) { propData = propData.replaceAll("\\{" + e.getKey() + "\\}", (String) e.getValue()); }/*from ww w . j a v a2s .c om*/ final Properties props = new Properties(); props.load(new ByteArrayInputStream(propData.getBytes())); for (Map.Entry e : overrides.entrySet()) { props.setProperty((String) e.getKey(), (String) e.getValue()); } ConfigurationManager.getConfigInstance().clear(); ConfigurationManager.loadProperties(props); }
From source file:org.anon.license.Lincese3JLicenseManagerTest.java
protected void check(String file) throws IOException, FileNotFoundException { Lincese3JLicenseManager licenseManager = new Lincese3JLicenseManager(); Properties properties = new Properties(); properties.load(new FileReader(file)); licenseManager.licenseSignature = properties.getProperty("licenseSignature"); licenseManager.initLicense();// w w w . j av a2 s .c om licenseManager.checkLicenseExpired(); }
From source file:org.darwinathome.server.email.EnhancedJavaMailSenderImpl.java
@Override public void setUsername(String userName) { if (userName.contains("gmail.com")) { Properties props = new Properties(); props.put("mail.smtp.host", "smtp.gmail.com"); props.put("mail.smtp.port", "587"); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); super.setJavaMailProperties(props); }// ww w. j a v a2s.c o m super.setUsername(userName); }
From source file:test.SomeMainClass.java
private static String dumpConfiguration(Configuration configuration) { StringBuilder sb = new StringBuilder("Config@" + configuration.hashCode()); sb.append("\n"); sb.append(configuration.toString()); sb.append("\n"); Properties props = new Properties(); if (configuration != null) { for (Map.Entry<String, String> entry : configuration) { props.setProperty(entry.getKey(), entry.getValue()); }/*from ww w . ja va 2 s . c o m*/ } return sb.append(props.toString()).toString(); }