List of usage examples for java.util Properties store
public void store(OutputStream out, String comments) throws IOException
From source file:org.atomserver.testutils.client.MockRequestContext.java
public void setPropertiesAsText(Properties props) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); props.store(out, null); setContentAsText(out.toString());//from w w w . ja v a2 s .com }
From source file:com.cloudmine.api.BaseDeviceIdentifier.java
private void savePropertiesFile(Properties toSave) { File idFile = new File(PROPERTIES_FILE); try {// ww w . j ava 2 s . co m FileOutputStream writer = new FileOutputStream(idFile); toSave.store(writer, ""); } catch (FileNotFoundException e) { } catch (IOException e) { } }
From source file:org.globus.security.provider.FileBasedKeyStoreTest.java
@Test public void testIO() throws Exception { InputStream is;//www . j av a 2s . c o m ByteArrayOutputStream os; Properties props = new Properties(); props.put(PEMKeyStore.KEY_FILENAME, "classpath:/key.pem"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); props.store(baos, "sample"); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); keystore.engineLoad(bais, null); Enumeration en = keystore.engineAliases(); while (en.hasMoreElements()) { System.out.println("en.nextElement().toString() = " + en.nextElement().toString()); } os = new ByteArrayOutputStream(); // keystore.engineStore(os, null); // keystore.engineStore(os, password); }
From source file:it.isislab.dmason.util.SystemManagement.Worker.Digester.java
public void storeToPropFile(String path) throws NoDigestFoundException { if (digest == null) throw new NoDigestFoundException(); else {//from w w w. j av a 2s . c om Properties prop = new Properties(); try { prop.setProperty(digestAlg, digest); prop.store(new FileOutputStream(path), null); } catch (IOException ex) { ex.printStackTrace(); } } }
From source file:com.bekwam.mavenpomupdater.data.IOUtils.java
public void setProperties(FileContents fc, String key, String value, String comment) throws IOException { OutputStream os = null;/*from w w w .j ava 2 s . co m*/ Properties properties = new Properties(); try { os = fc.getOutputStream(true); // true -> overwrite properties.put(key, value); properties.store(os, comment); } finally { try { if (os != null) { os.close(); } } catch (IOException exc) { log.warn("can't close output stream", exc); } } }
From source file:gobblin.yarn.JobConfigurationManagerTest.java
@BeforeClass public void setUp() throws IOException { this.eventBus.register(this); // Prepare the test job configuration files Assert.assertTrue(jobConfigFileDir.mkdirs()); Closer closer = Closer.create();//from w w w . jav a 2 s .c om try { for (int i = 0; i < NUM_JOB_CONFIG_FILES; i++) { File jobConfigFile = new File(this.jobConfigFileDir, "test" + i + ".job"); Assert.assertTrue(jobConfigFile.createNewFile()); Properties properties = new Properties(); properties.setProperty("foo", "bar" + i); properties.store( closer.register(Files.newWriter(jobConfigFile, ConfigurationKeys.DEFAULT_CHARSET_ENCODING)), ""); } } catch (Throwable t) { throw closer.rethrow(t); } finally { closer.close(); } this.jobConfigurationManager = new JobConfigurationManager(this.eventBus, Optional.of(JOB_CONFIG_DIR_NAME)); this.jobConfigurationManager.startAsync().awaitRunning(); }
From source file:com.google.mr4c.content.AbstractContentFactory.java
public void writeContent(URI uri, Properties props) throws IOException { Writer writer = getWriterForContent(uri); try {/*from ww w .ja v a 2 s . c om*/ props.store(writer, ""); } finally { writer.close(); } }
From source file:gobblin.cluster.JobConfigurationManagerTest.java
@BeforeClass public void setUp() throws IOException { this.eventBus.register(this); // Prepare the test job configuration files Assert.assertTrue(this.jobConfigFileDir.mkdirs(), "Failed to create " + this.jobConfigFileDir); Closer closer = Closer.create();// w ww. j ava 2 s.c om try { for (int i = 0; i < NUM_JOB_CONFIG_FILES; i++) { File jobConfigFile = new File(this.jobConfigFileDir, "test" + i + ".job"); Assert.assertTrue(jobConfigFile.createNewFile()); Properties properties = new Properties(); properties.setProperty("foo", "bar" + i); properties.store( closer.register(Files.newWriter(jobConfigFile, ConfigurationKeys.DEFAULT_CHARSET_ENCODING)), ""); } } catch (Throwable t) { throw closer.rethrow(t); } finally { closer.close(); } Config config = ConfigFactory.empty().withValue(GobblinClusterConfigurationKeys.JOB_CONF_PATH_KEY, ConfigValueFactory.fromAnyRef(JOB_CONFIG_DIR_NAME)); this.jobConfigurationManager = new JobConfigurationManager(this.eventBus, config); this.jobConfigurationManager.startAsync().awaitRunning(); }
From source file:cd.go.contrib.elasticagents.docker.requests.CreateAgentRequest.java
public String autoregisterPropertiesAsString(String elasticAgentId) { Properties properties = autoregisterProperties(elasticAgentId); StringWriter writer = new StringWriter(); try {/*from w w w . j a va 2 s . c o m*/ properties.store(writer, ""); } catch (IOException e) { throw new RuntimeException(e); } return writer.toString(); }
From source file:es.juntadeandalucia.framework.ticket.impl.DefaultTicket.java
public String getTicket(Map<String, String> map) throws Exception { if (ticketLifeTime > 0) { map.put(TIME_TICKET_EXPIRY, Long.toString(getCurrentTimeMillisUTC() + ticketLifeTime)); }/*w ww .j a v a 2s . c om*/ try { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Properties properties = toProperties(map); properties.store(outputStream, "ticket component"); //$NON-NLS-1$ byte[] bs = crypt(outputStream.toByteArray()); return Base32.encode(bs); } catch (Exception e) { e = new Exception(msg.getString("ticket.error.ticketobtainingerror")); //$NON-NLS-1$ log.warn(e); //$NON-NLS-1$ throw e; } // return null; }