List of usage examples for java.util Properties setProperty
public synchronized Object setProperty(String key, String value)
From source file:Main.java
public final static void setOutputProperty(final Properties prop, final String key, final boolean b) { prop.setProperty(key, toOutputPropertyValue(b)); }
From source file:Main.java
public static String getXml(Document doc) { DOMSource doms = new DOMSource(doc); StringWriter sw = new StringWriter(); StreamResult sr = new StreamResult(sw); String xml = null;// w ww . jav a2 s . c o m try { TransformerFactory tf = TransformerFactory.newInstance(); Transformer t = tf.newTransformer(); Properties properties = t.getOutputProperties(); properties.setProperty(OutputKeys.ENCODING, "GB2312"); properties.setProperty(OutputKeys.METHOD, "xml");//! properties.setProperty(OutputKeys.VERSION, "1.0"); properties.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); t.setOutputProperties(properties); t.transform(doms, sr); String dtd = doc.getDoctype().getInternalSubset(); if ((null != dtd) && (dtd.length() > 0)) { dtd = "\n<!DOCTYPE Catalog [\n" + dtd + "]>\n"; } ; xml = "<?xml version=\"1.0\" encoding=\"GB2312\"?>" + dtd; xml += sw.toString(); } catch (TransformerConfigurationException tce) { //"Transformer Configuration Exception\n-----" } catch (TransformerException te) { //"Transformer Exception\n---------" } return xml; }
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:com.silverpeas.util.template.SilverpeasTemplateFactory.java
public static SilverpeasTemplate createSilverpeasTemplateOnCore(final String pathSuffix) { final Properties config = new Properties(); config.setProperty(SilverpeasTemplate.TEMPLATE_ROOT_DIR, computePath(SilverpeasStringTemplateUtil.defaultCoreDir, pathSuffix)); config.setProperty(SilverpeasTemplate.TEMPLATE_CUSTOM_DIR, computePath(SilverpeasStringTemplateUtil.customCoreDir, pathSuffix)); return createSilverpeasTemplate(config); }
From source file:Main.java
public static void addHandset(String file, String name, Hashtable<String, String> attri) throws Exception { DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance(); DocumentBuilder dombuilder = domfac.newDocumentBuilder(); FileInputStream is = new FileInputStream(file); Document doc = dombuilder.parse(is); NodeList nodeList = doc.getElementsByTagName("devices"); if (nodeList != null && nodeList.getLength() >= 1) { Node deviceNode = nodeList.item(0); Element device = doc.createElement("device"); device.setTextContent(name);/*from w w w . ja v a2 s. c om*/ for (Iterator itrName = attri.keySet().iterator(); itrName.hasNext();) { String attriKey = (String) itrName.next(); String attriValue = (String) attri.get(attriKey); device.setAttribute(attriKey, attriValue); } deviceNode.appendChild(device); } //save TransformerFactory tf = TransformerFactory.newInstance(); Transformer t = tf.newTransformer(); Properties props = t.getOutputProperties(); props.setProperty(OutputKeys.ENCODING, "GB2312"); t.setOutputProperties(props); DOMSource dom = new DOMSource(doc); StreamResult sr = new StreamResult(file); t.transform(dom, sr); }
From source file:Main.java
public static void save(String paramString, Document paramDocument) throws Exception { DOMSource localDOMSource = new DOMSource(paramDocument); File localFile1 = new File(paramString); File localFile2 = localFile1.getParentFile(); localFile2.mkdirs();//from w ww .java2 s .c om StreamResult localStreamResult = new StreamResult(localFile1); try { TransformerFactory localTransformerFactory = TransformerFactory.newInstance(); Transformer localTransformer = localTransformerFactory.newTransformer(); Properties localProperties = localTransformer.getOutputProperties(); localProperties.setProperty("encoding", "UTF-8"); localProperties.setProperty("indent", "yes"); localTransformer.setOutputProperties(localProperties); localTransformer.transform(localDOMSource, localStreamResult); } catch (TransformerConfigurationException localTransformerConfigurationException) { localTransformerConfigurationException.printStackTrace(); } catch (TransformerException localTransformerException) { localTransformerException.printStackTrace(); } }
From source file:ezbake.crypto.utils.TestExternalHttps.java
private static HttpClient getSSLHttpClient() { HttpClient httpClient;/*from w ww . j a v a2s.c om*/ Properties serverProps = new Properties(); serverProps.setProperty(EzBakePropertyConstants.EZBAKE_CERTIFICATES_DIRECTORY, "src/test/resources"); serverProps.setProperty(EzBakePropertyConstants.EZBAKE_SECURITY_ID, "appId"); serverProps.setProperty(EzBakePropertyConstants.EZBAKE_APPLICATION_KEYSTORE_FILE, "keystore.jks"); serverProps.setProperty(EzBakePropertyConstants.EZBAKE_APPLICATION_KEYSTORE_TYPE, "JKS"); serverProps.setProperty(EzBakePropertyConstants.EZBAKE_APPLICATION_KEYSTORE_PASS, "password"); try { httpClient = HttpClients.custom().setSslcontext(EzSSL.getSSLContext(serverProps)).build(); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("IO Exception reading keystore/truststore file: " + e.getMessage()); } return httpClient; }
From source file:Main.java
/** * Don't add this property if it's equal to its default value. *//*from w ww . j a v a 2s . c o m*/ public static void setProperty(Properties p, String name, String value, String def) { if (!def.equals(value) && value != null) { p.setProperty(name, value); } }
From source file:Main.java
public static void addApp(String file, String name, Hashtable<String, String> attri) throws Exception { DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance(); DocumentBuilder dombuilder = domfac.newDocumentBuilder(); FileInputStream is = new FileInputStream(file); Document doc = dombuilder.parse(is); NodeList nodeList = doc.getElementsByTagName("app"); if (nodeList != null && nodeList.getLength() >= 1) { Node deviceNode = nodeList.item(0); Element device = doc.createElement("aut"); device.setTextContent(name);//from ww w .j a v a 2 s . c om for (Iterator itrName = attri.keySet().iterator(); itrName.hasNext();) { String attriKey = (String) itrName.next(); String attriValue = (String) attri.get(attriKey); device.setAttribute(attriKey, attriValue); } deviceNode.appendChild(device); } //save TransformerFactory tf = TransformerFactory.newInstance(); Transformer t = tf.newTransformer(); Properties props = t.getOutputProperties(); props.setProperty(OutputKeys.ENCODING, "GB2312"); t.setOutputProperties(props); DOMSource dom = new DOMSource(doc); StreamResult sr = new StreamResult(file); t.transform(dom, sr); }
From source file:io.pivotal.gemfire.main.GemFireServerApplication.java
static Properties gemfireProperties() { Properties gemfireProperties = new Properties(); gemfireProperties.setProperty("name", GemFireServerApplication.class.getSimpleName()); gemfireProperties.setProperty("mcast-port", "0"); gemfireProperties.setProperty("log-level", systemProperty("gemfire.log.level", "config")); gemfireProperties.setProperty("locators", systemProperty("gemfire.locator.host-port", "localhost[11235]")); gemfireProperties.setProperty("start-locator", systemProperty("gemfire.locator.host-port", "localhost[11235]")); gemfireProperties.setProperty("jmx-manager", "true"); gemfireProperties.setProperty("jmx-manager-port", systemProperty("gemfire.manager.port", "1199")); gemfireProperties.setProperty("jmx-manager-start", "true"); return gemfireProperties; }