List of usage examples for java.util Properties storeToXML
public void storeToXML(OutputStream os, String comment) throws IOException
From source file:org.exoplatform.platform.common.software.register.Utils.java
public static void writeToFile(String key, String value, String fileLocation) { if (fileLocation == null || fileLocation.isEmpty()) { throw new IllegalArgumentException("Illegal empty file Location parameter."); }/*from ww w .j a va2s .c o m*/ InputStream inputStream = null; OutputStream outputStream = null; try { Properties properties = new Properties(); File file = new File(fileLocation); if (file.exists()) { inputStream = new FileInputStream(fileLocation); properties.loadFromXML(inputStream); inputStream.close(); } else { verifyAndCreateParentFolder(fileLocation); } properties.put(key, value); outputStream = new FileOutputStream(fileLocation); properties.storeToXML(outputStream, ""); outputStream.close(); } catch (Exception exception) { if (outputStream != null) { try { outputStream.close(); } catch (IOException ioException) { LOG.error("Error during close outputStream ", ioException); } } if (inputStream != null) { try { inputStream.close(); } catch (IOException ioException) { LOG.error("Error during close inputStream ", ioException); } } } }
From source file:org.escidoc.browser.elabsmodul.service.ELabsService.java
private static List<String[]> buildConfiguration(final List<Map<String, String>> list) { Preconditions.checkNotNull(list, "Config list is null"); final List<String[]> result = new ArrayList<String[]>(); if (list.isEmpty()) { LOG.error("There is not ConfigMap to process!"); return null; }/*from w w w . j a v a2s. com*/ for (final Map<String, String> map : list) { final Properties config = new Properties(); config.putAll(map); if (!config.isEmpty()) { LOG.debug(config.toString()); final ByteArrayOutputStream out = new ByteArrayOutputStream(); try { config.storeToXML(out, ""); LOG.debug("Configuration Properties XML \n" + out.toString()); } catch (final IOException e) { LOG.error(e.getMessage()); } result.add(new String[] { config.getProperty(ELabsServiceConstants.E_SYNC_DAEMON_ENDPOINT), out.toString() }); } else { LOG.error("Configuration is empty!"); } } return result; }
From source file:com.xiongyingqi.util.DefaultPropertiesPersister.java
@Override public void storeToXml(Properties props, OutputStream os, String header) throws IOException { props.storeToXML(os, header); }
From source file:com.bigdata.rdf.properties.xml.PropertiesXMLWriter.java
@Override public void write(final Properties properties) throws IOException { properties.storeToXML(os, null/*comment*/); }
From source file:ar.com.zauber.commons.web.proxy.impl.dao.properties.persister.FilesystemPropertiesPersister.java
/** @see PropertiesPersister#save(Properties) */ public final void save(final Properties properties) { try {/*w ww .j a v a 2 s . c o m*/ final OutputStream os = new FileOutputStream(file); try { properties.storeToXML(os, new Date().toString()); } finally { os.close(); } } catch (final IOException e) { throw new UnhandledException(e); } }
From source file:com.websqrd.catbot.setting.CatbotSettings.java
private static void storeXmlProperties(Properties props, String xmlFilename) { String configFile = getKey(xmlFilename); logger.debug("Store properties = {}", configFile); FileOutputStream writer = null; try {/*ww w . ja v a 2 s . c o m*/ writer = new FileOutputStream(configFile); props.storeToXML(writer, new Date().toString()); putToCache(props, xmlFilename); } catch (IOException e) { logger.error(e.getMessage(), e); } finally { try { writer.close(); } catch (IOException e) { //ignore } } }
From source file:com.opensource.frameworks.processframework.utils.DefaultPropertiesPersister.java
public void storeToXml(Properties props, OutputStream os, String header) throws IOException { try {//from www . j a v a2 s .c o m props.storeToXML(os, header); } catch (NoSuchMethodError err) { throw new IOException( "Cannot store properties XML file - not running on JDK 1.5+: " + err.getMessage()); } }
From source file:de.escidoc.bwelabs.deposit.DepositServiceSpec.java
private OutputStream toXml(Properties adapted) throws IOException { OutputStream os = new ByteArrayOutputStream(); adapted.storeToXML(os, "From functional testing."); return os;// w ww. j a v a 2 s . c o m }
From source file:ua.com.ecotep.unianalysis.security.ConfigParamsContext.java
@Override public void setServerConfigParams(ServerConfigParams params) throws Exception { DataOutputStream out = null;// w w w .ja va2s .c o m ConfigEncoder ce = new ConfigEncoderImpl(); File file = new File("unianalysis.xml"); Properties properties = new Properties(); if (!file.exists()) { file.createNewFile(); properties.setProperty("serverpath", new String(Base64.encodeBase64(ce.encode(params.getDbserver())))); properties.setProperty("user", new String(Base64.encodeBase64(ce.encode(params.getDbusername())))); properties.setProperty("md5", new String(Base64.encodeBase64(ce.encode(params.getDbpassword())))); properties.storeToXML(new FileOutputStream(file), ""); } }
From source file:com.adaptris.core.services.metadata.ReadMetadataFromFilesystemTest.java
private void writeProperties(Properties p, File filename, boolean xml) throws Exception { OutputStream out = null;// w w w.j av a 2 s . c o m try { File parent = filename.getParentFile(); if (parent != null) { parent.mkdirs(); } out = new FileOutputStream(filename); if (xml) { p.storeToXML(out, ""); } else { p.store(out, ""); } } finally { IOUtils.closeQuietly(out); } }