List of usage examples for java.util Properties store
public void store(OutputStream out, String comments) throws IOException
From source file:com.splunk.shuttl.server.mbeans.OverrideWithOldArchiverRootURIConfiguration.java
private void writeToPropertiesFile(Properties props, File file) throws IOException { logger.warn("Writing properties: " + props + ", to properties file: " + file + ", overriding any previous configuration."); props.store(FileUtils.openOutputStream(file), overrideReason); }
From source file:de.micromata.genome.logging.spi.FileLogConfigurationDAOImpl.java
/** * Store properties.//from w w w.j a v a 2 s . co m * * @param p the p */ protected void storeProperties(Properties p) { String pfile = getPropertyFileName(); try { File pf = new File(pfile); p.store(new FileOutputStream(pf), "# Genome LogConfiguration"); } catch (IOException ex) { throw new LoggedRuntimeException(LogLevel.Warn, GenomeLogCategory.Configuration, "Cannot store GenomeLogConfiguration: " + ex.getMessage(), new LogAttribute(GenomeAttributeType.Miscellaneous, pfile), new LogExceptionAttribute(ex)); } }
From source file:com.enonic.cms.core.boot.ConfigBuilderTest.java
private void setupClassPathProperties() throws Exception { Properties props = new Properties(); props.setProperty("classpath.param", "value"); props.setProperty("override", "classpath"); ByteArrayOutputStream out = new ByteArrayOutputStream(); props.store(out, ""); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); Mockito.when(this.classLoader.getResourceAsStream("com/enonic/vertical/default.properties")).thenReturn(in); }
From source file:cz.cas.lib.proarc.common.config.AppConfigurationTest.java
private File createConfigFile(Properties props, File configFile) throws IOException { FileOutputStream propsOut = new FileOutputStream(configFile); props.store(propsOut, null); propsOut.close();//w w w. java2 s . co m assertTrue(configFile.exists()); return configFile; }
From source file:com.sugarcrm.candybean.configuration.Configuration.java
private void store(Properties properties, File file) throws IOException { try {/*from w ww . j av a 2s . c o m*/ properties.store(new FileOutputStream(file), ""); } catch (IOException e) { logger.warning("Unable to store " + file.getCanonicalPath() + ".\n"); logger.severe(e.getMessage()); } }
From source file:net.dempsy.distconfig.apahcevfs.ApacheVfsPropertiesStore.java
@Override public int push(final Properties props) throws IOException { return mapChecked(() -> { final FileObject next = nextFile(getLatest(parentDirObj), parentDirObj); try (OutputStream os = next.getContent().getOutputStream()) { props.store(os, COMMENT); }//w w w . jav a 2 s .co m return new Integer(getVersion(next)); }, em).intValue(); }
From source file:com.github.jrh3k5.plugin.maven.l10n.data.AbstractMessagesPropertiesParserTest.java
/** * Test the loading of translation keys. * /*from w ww. j a va 2 s .c om*/ * @throws Exception * If any errors occur during the test run. */ @Test public void testGetTranslationKeys() throws Exception { final File messagesFile = getTestFile("messages.properties"); final String messageKey = UUID.randomUUID().toString(); final Properties sourceProperties = new Properties(); sourceProperties.put(messageKey, UUID.randomUUID().toString()); try (final OutputStream outputStream = new FileOutputStream(messagesFile)) { sourceProperties.store(outputStream, null); } assertThat(parser.getTranslationKeys(messagesFile)).hasSize(1).contains(messageKey); }
From source file:gobblin.scheduler.JobConfigFileMonitorTest.java
@Test(dependsOnMethods = { "testChangeJobConfigFile" }) public void testUnscheduleJob() throws Exception { final Logger log = LoggerFactory.getLogger("testUnscheduleJob"); log.info("testUnscheduleJob: start"); Assert.assertEquals(this.jobScheduler.getScheduledJobs().size(), 4); // Disable the new job by setting job.disabled=true Properties jobProps = new Properties(); jobProps.load(new FileReader(this.newJobConfigFile)); jobProps.setProperty(ConfigurationKeys.JOB_DISABLED_KEY, "true"); jobProps.store(new FileWriter(this.newJobConfigFile), null); AssertWithBackoff.create().logger(log).timeoutMs(7500).assertEquals(new GetNumScheduledJobs(), 3, "3 scheduled jobs"); Set<String> jobNames = Sets.newHashSet(this.jobScheduler.getScheduledJobs()); Assert.assertEquals(jobNames.size(), 3); Assert.assertTrue(jobNames.contains("GobblinTest1")); Assert.assertTrue(jobNames.contains("GobblinTest2")); Assert.assertTrue(jobNames.contains("GobblinTest3")); log.info("testUnscheduleJob: end"); }
From source file:hr.fer.zemris.vhdllab.platform.preference.DatabasePreferences.java
@Override protected void flushSpi() throws BackingStoreException { Properties props = getProperties(); if (!props.isEmpty()) { StringWriter writer = new StringWriter(); try {/*from w ww. j ava 2 s . c o m*/ props.store(writer, null); } catch (IOException e) { throw new UnhandledException(e); } PreferencesFile file = getFile(); String data = writer.toString(); if (file == null) { file = new PreferencesFile(absolutePath(), data); } else { file.setData(data); } manager.setFile(file); } }
From source file:com.opensource.frameworks.processframework.utils.DefaultPropertiesPersister.java
public void store(Properties props, Writer writer, String header) throws IOException { if (storeToWriterAvailable) { // On JDK 1.6+ props.store(writer, header); } else {// w w w . j a va2 s .com // Fall back to manual parsing. doStore(props, writer, header); } }