Example usage for java.util Properties store

List of usage examples for java.util Properties store

Introduction

In this page you can find the example usage for java.util Properties store.

Prototype

public void store(OutputStream out, String comments) throws IOException 

Source Link

Document

Writes this property list (key and element pairs) in this Properties table to the output stream in a format suitable for loading into a Properties table using the #load(InputStream) load(InputStream) method.

Usage

From source file:de.unihannover.se.processSimulation.interactive.ServerMain.java

private void storeProperties(Properties p, File requestDir, String name, String comment) throws IOException {
    try (FileOutputStream out = new FileOutputStream(new File(requestDir, name))) {
        p.store(out, comment);
    }//from   w w w. j av a  2s  .c  o  m
}

From source file:net.cliseau.composer.javacor.MissingToolException.java

/**
 * Create the policy parameters file./*from   w ww. j a  v  a2 s . com*/
 *
 * This creates the policy parameters file and adds it to the list of
 * all files in archiveFileNames.
 *
 * @exception InvalidConfigurationException Thrown when some required configuration could not be obtained.
 * @exception FileNotFoundException Thrown when the destination configuration file could not be created.
 * @exception IOException Thrown when writing the configuration file fails.
 * @todo This method is public only to be called by AspectWeaverFSI. This
 *       is not very elegant and should be resolved differently.
 */
public void createPolicyConfigurationFile(Collection<String> archiveFileNames)
        throws InvalidConfigurationException, FileNotFoundException, IOException {
    Properties policyParams = new Properties();
    policyParams.putAll(config.getLocalPolicyParameters());
    final File policyParamFile = new File(getDestinationDirectory() + File.separator + policyParamsFileName);
    policyParams.store(new FileOutputStream(policyParamFile), null);
    archiveFileNames.add(policyParamFile.getAbsolutePath());
}

From source file:com.adaptris.core.services.metadata.SimpleSequenceNumberTest.java

private void createPropertyFile(String filename, int seq) throws Exception {
    Properties p = new Properties();
    p.setProperty(SERVICE_PROPERTY_KEY, String.valueOf(seq));
    OutputStream out = null;//from  ww  w.  j av  a 2 s  .  c  om
    try {
        out = new FileOutputStream(new File(filename));
        p.store(out, "");
    } finally {
        IOUtils.closeQuietly(out);
    }
}

From source file:com.twinsoft.convertigo.engine.EnginePropertiesManager.java

public static void saveProperties(OutputStream outputStream, String comments)
        throws IOException, EngineException {
    Properties modifiedProperties = new Properties();
    for (PropertyName property : PropertyName.values()) {
        String propertyValue = getOriginalProperty(property);
        if (!property.getDefaultValue().equals(propertyValue)) {
            if (property.isCiphered()) {
                propertyValue = Crypto2.encodeToHexString(propertyValue);
            }/*  www  .  j  a  va2  s. c  o  m*/
            modifiedProperties.put(property.getKey(), propertyValue);
        }
    }
    modifiedProperties.store(outputStream, comments);
}

From source file:it.scoppelletti.sdk.schemaupdate.RoleCreator.java

/**
 * Crea una coppia (ruolo, descrizione).
 * //from w w w  .j a  v  a2  s .  c  o  m
 * @param file File di propriet&agrave;.
 * @param desc Descrizione.
 */
private void createRole(File file, String desc) {
    Properties props;
    OutputStream out = null;
    ProgramResources res = new ProgramResources();

    props = loadProperties(file);
    if (props.containsKey(myCode)) {
        myUI.display(MessageType.WARNING, res.getRoleAlreadyExistException(myCode, file));
        return;
    }

    props.setProperty(myCode, desc);

    try {
        out = new FileOutputStream(file);
        props.store(out, null);
    } catch (IOException ex) {
        throw new IOOperationException(ex);
    } finally {
        if (out != null) {
            IOUtils.close(out);
            out = null;
        }
    }

    myUI.display(MessageType.INFORMATION, res.getRoleSavedMessage(myCode, desc, file));
}

From source file:de.codesourcery.eve.skills.ui.config.AppConfig.java

public void save() throws IOException {

    log.debug("save(): Saving app config to " + file);

    final Properties props = new Properties();

    for (Map.Entry<String, String> e : this.entrySet()) {
        props.setProperty(e.getKey(), e.getValue());
    }/*  ww  w . j  a v a2  s  .co m*/

    final Writer out = new FileWriter(file, false);
    try {
        props.store(out, "Automatically generated, DO NOT EDIT.");
    } finally {
        out.close();
    }
}

From source file:de.unidue.ltl.pos.trainmodel.tc.PostPosUpdateTask.java

private void writeAccuracyFile(TaskContext aContext) throws IOException {
    // file to hold prediction results
    File evalFile = aContext.getFile(
            CRFSuiteAdapter.getInstance().getFrameworkFilename(AdapterNameEntries.evaluationFile),
            AccessMode.READWRITE);

    Properties p = new Properties();
    p.setProperty(ReportConstants.CORRECT, correct + "");
    p.setProperty(ReportConstants.INCORRECT, incorrect + "");
    p.setProperty(ReportConstants.PCT_CORRECT, (correct / (correct + incorrect)) + "");
    p.store(new FileOutputStream(evalFile), "results of post processing");
}

From source file:com.neophob.sematrix.core.glue.FileUtils.java

/**
 * Save presents./*ww w.  j  a  va2  s  . com*/
 */
public void savePresents(List<PresetSettings> presets) {
    Properties props = new Properties();
    int idx = 0;
    for (PresetSettings p : presets) {
        props.setProperty("" + idx, p.getSettingsAsString());
        idx++;
    }

    OutputStream output = null;
    try {
        String filename = this.getDataDir() + File.separator + PRESETS_FILENAME;
        output = new FileOutputStream(filename);
        props.store(output, "Visual Daemon presets file");
        LOG.log(Level.INFO, "Presets saved as {0}", PRESETS_FILENAME);
    } catch (Exception e) {
        LOG.log(Level.WARNING, "Failed to save {0}, Error: {1}", new Object[] { PRESETS_FILENAME, e });
    } finally {
        try {
            if (output != null) {
                output.close();
            }
        } catch (Exception e) {
            LOG.log(Level.WARNING, "Failed to close output stream", e);
        }
    }
}

From source file:com.uber.hoodie.common.model.HoodieTableMetadata.java

/**
 * Initialize the hoodie meta directory and any necessary files inside the meta (including the hoodie.properties)
 *
 * @param metadataFolder// ww  w  . jav a2  s  . c o  m
 * @param tableName
 * @throws IOException
 */
private void createHoodieProperties(Path metadataFolder, String tableName) throws IOException {
    if (!fs.exists(metadataFolder)) {
        fs.mkdirs(metadataFolder);
    }
    Path propertyPath = new Path(metadataFolder, HOODIE_PROPERTIES_FILE);
    FSDataOutputStream outputStream = fs.create(propertyPath);
    try {
        Properties props = new Properties();
        props.setProperty(HOODIE_TABLE_NAME_PROP_NAME, tableName);
        props.setProperty(HOODIE_TABLE_TYPE_PROP_NAME, DEFAULT_TABLE_TYPE.name());
        props.store(outputStream, "Properties saved on " + new Date(System.currentTimeMillis()));
    } finally {
        outputStream.close();
    }
}

From source file:com.tc.l2.logging.TCLoggingTest.java

@Test
public void testDeveloperOverlay() throws Exception {
    Properties classpath = new Properties();
    Properties userhome = new Properties();
    Properties userdir = new Properties();

    classpath.setProperty("whoami", "classpath");
    userhome.setProperty("whoami", "userhome");
    userdir.setProperty("whoami", "userdir");

    ByteArrayOutputStream classbytes = new ByteArrayOutputStream();
    ByteArrayOutputStream homebytes = new ByteArrayOutputStream();
    ByteArrayOutputStream dirbytes = new ByteArrayOutputStream();

    classpath.store(classbytes, null);
    userhome.store(homebytes, null);/*  w  ww .j a va  2s  . c o  m*/
    userdir.store(dirbytes, null);

    Assert.assertEquals(
            ((TCLoggingLog4J) TCLogging.getLoggingService()).layerDevelopmentConfiguration(
                    Arrays.asList(new ByteArrayInputStream(classbytes.toByteArray()),
                            new ByteArrayInputStream(homebytes.toByteArray()),
                            new ByteArrayInputStream(dirbytes.toByteArray())))
                    .getProperty("whoami"),
            "userdir");
    // make sure empty streams return a valid props file
    Assert.assertNotNull(((TCLoggingLog4J) TCLogging.getLoggingService())
            .layerDevelopmentConfiguration(Arrays.asList(new ByteArrayInputStream(new byte[0]),
                    new ByteArrayInputStream(new byte[0]), new ByteArrayInputStream(new byte[0]))));
    // make sure an empty list returns null
    Assert.assertNull(((TCLoggingLog4J) TCLogging.getLoggingService())
            .layerDevelopmentConfiguration(Collections.<InputStream>emptyList()));
}