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:Main.java

public static void saveConfig(Context context, String file, Properties properties) {
    try {//  ww w  .j a v  a  2s . c  om
        FileOutputStream s = new FileOutputStream(file, false);
        properties.store(s, "");
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void saveProperties(Context context, String file, String encode, Properties properties)
        throws Exception {
    FileOutputStream s = new FileOutputStream(file, false);
    properties.store(s, "");
}

From source file:com.l2jfree.security.HexID.java

/**
 * Save hexadecimal ID of the server in the properties file.
 * /* w w w.j  a v  a 2 s. c  o  m*/
 * @param string (String) : hexadecimal ID of the server to store
 * @param fileName (String) : name of the properties file
 */
public static void saveHexid(String string, String fileName) {
    OutputStream out = null;
    try {
        out = new FileOutputStream(fileName);

        final Properties hexSetting = new Properties();
        hexSetting.setProperty("HexID", string);
        hexSetting.store(out, "the hexID to auth into login");
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        IOUtils.closeQuietly(out);
    }
}

From source file:com.sosee.util.PropertyUtil.java

public static void writePropertiesFile(String key, String value) {
    Properties properties = new Properties();
    try {//from  w  w  w  . ja  va 2  s  . c  o m
        OutputStream outputStream = new FileOutputStream(getFilePath());
        properties.setProperty(key, value);

        properties.store(outputStream, "user register");
        outputStream.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:de.micromata.genome.gwiki.utils.PropUtils.java

public static String fromProperties(Properties props) {
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    try {/*from  www  .j av  a2 s . co  m*/
        props.store(bout, "");
        return new String(bout.toByteArray(), PROPS_ENCODING);
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}

From source file:com.amazonaws.services.kinesis.producer.KinesisProducerConfigurationTest.java

private static String writeFile(Properties p) {
    try {//from   www  . j a v a  2 s.c o  m
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        p.store(baos, "");
        baos.close();
        return writeFile(new String(baos.toByteArray(), "UTF-8"));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:com.antonjohansson.elasticsearchshell.utils.PropertiesUtils.java

/**
 * Writes the given properties to the given file.
 */// w  w w .j  av a 2  s . co  m
public static void write(Properties properties, File file) {
    OutputStream output = null;
    try {
        output = new FileOutputStream(file);
        properties.store(output, "");
    } catch (Exception e) {
        throw new RuntimeException(e);
    } finally {
        closeQuietly(output);
    }
}

From source file:io.fluo.mapreduce.FluoOutputFormat.java

/**
 * Call this method to initialize the Fluo connection props and {@link LoaderExecutorImpl} props
 * //from w  w  w.ja v  a  2 s .  c  o  m
 * @param conf
 * @param props
 *          Use {@link io.fluo.api.config.FluoConfiguration} to set props programmatically
 */

public static void configure(Job conf, Properties props) {
    try {

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        props.store(baos, "");

        conf.getConfiguration().set(PROPS_CONF_KEY, new String(baos.toByteArray(), "UTF8"));

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:Main.java

/**
 * (android) write to file//from w  ww . j av  a 2 s .c o m
 * 
 * @param fileName
 * @param toSave
 * @return
 */
public static boolean androidFileSave(Context con, String fileName, String toSave) {
    Properties properties = new Properties();
    properties.put(FILE_ENCODING, toSave);
    try {
        FileOutputStream stream = con.openFileOutput(fileName, Context.MODE_WORLD_WRITEABLE);
        properties.store(stream, "");
    } catch (FileNotFoundException e) {
        return false;
    } catch (IOException e) {
        return false;
    }

    return true;
}

From source file:com.floreantpos.license.FiveStarPOSLicenseGenerator.java

public static String generateLicense(Properties templateProperties, InputStream privateKeyInputStream,
        File licenseFile) throws FileNotFoundException, NoSuchAlgorithmException, InvalidKeySpecException,
        IOException, InvalidKeyException, SignatureException {

    PrivateKey privateKey = readPrivateKey(privateKeyInputStream);
    String encoded = templateProperties.toString();
    String signature = FiveStarPOSLicenseGenerator.sign(encoded.getBytes(), privateKey);

    OutputStream output = new FileOutputStream(licenseFile);
    Properties licenseProperties = new OrderedProperties();
    licenseProperties.putAll(templateProperties);
    licenseProperties.setProperty(License.SIGNATURE, signature);
    licenseProperties.store(output, "License file");
    output.close();/* ww w  .jav a 2  s  . c o m*/

    return signature;
}