Example usage for java.util Properties Properties

List of usage examples for java.util Properties Properties

Introduction

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

Prototype

public Properties() 

Source Link

Document

Creates an empty property list with no default values.

Usage

From source file:io.s4.latin.adapter.TwitterFeedListener.java

public static void main(String[] args) {
    Properties props = new Properties();
    props.setProperty("user", "");
    props.setProperty("password", "");
    props.setProperty("url", "http://stream.twitter.com/1/statuses/sample.json");
    props.setProperty("stream", "TestStream");

    TwitterFeedListener a = new TwitterFeedListener(props);
    a.init();/*from  www .  ja v  a  2  s  . c  om*/
}

From source file:PrintSampleApp.java

public PrintSampleApp() {
    add("Center", canvas);
    setSize(500, 500);//  w  w  w.j  ava 2s  .  co  m
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);
    String name = "Test print job";
    Properties properties = new Properties();
    PrintJob pj = Toolkit.getDefaultToolkit().getPrintJob(PrintSampleApp.this, name, properties);
    if (pj != null) {
        canvas.printAll(pj.getGraphics());
        pj.end();
    }
}

From source file:org.psidnell.omnifocus.ApplicationContextFactory.java

public static Properties getConfigProperties() throws IOException {
    try (InputStream in = ApplicationContextFactory.class.getResourceAsStream(CONFIG_PROPERTIES)) {
        if (in == null) {
            throw new IOException("config not found");
        }//w  ww. jav  a2 s .  c o m
        Properties config = new Properties();
        config.load(in);
        return config;
    }
}

From source file:eu.serco.dhus.config.PropertiesLoader.java

public static Properties loadProperties(String propFileName) {
    InputStream inputStream = null;
    try {// ww  w.  j a v  a  2 s.c o m
        rulesProps = new Properties();

        inputStream = PropertiesLoader.class.getClassLoader().getResourceAsStream(propFileName);

        if (inputStream != null) {
            rulesProps.load(inputStream);
        } else {
            logger.error("property file '" + propFileName + "' not found in the classpath");
            throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath");
        }

    } catch (Exception e) {
        logger.error("Exception: " + e);
    } finally {
        if (inputStream != null)
            try {
                inputStream.close();
            } catch (IOException e) {
                logger.error("Error closing InputStream for properties file: " + e);
                e.printStackTrace();
            }
    }
    return rulesProps;

}

From source file:de.ingrid.interfaces.csw.admin.command.AdminManager.java

/**
 * Read the override configuration and convert the clear text password to a bcrypt-hash,
 * which is used and needed by the base-webapp v3.6.1 
 *//* w  ww.  jav  a  2  s.c  om*/
private static void migratePassword() {
    try {
        InputStream is = new FileInputStream("conf/config.properties");
        Properties props = new Properties();
        props.load(is);
        String oldPassword = props.getProperty("ingrid.admin.password");
        is.close();

        props.setProperty("ingrid.admin.password", BCrypt.hashpw(oldPassword, BCrypt.gensalt()));

        OutputStream os = new FileOutputStream("conf/config.override.properties");
        props.store(os, "Override configuration written by the application");
        os.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.seasbase.video.kafka.Consumer.java

private static ConsumerConfig createConsumerConfig() {
    Properties props = new Properties();
    props.put("zookeeper.connect", KafkaProperties.zkConnect);
    props.put("group.id", KafkaProperties.groupId);
    props.put("zookeeper.session.timeout.ms", "400");
    props.put("zookeeper.sync.time.ms", "200");
    props.put("auto.commit.interval.ms", "1000");

    return new ConsumerConfig(props);

}

From source file:com.partnet.automation.util.SystemPropsUtil.java

/**
 * Load properties from the given configuration file name.
 * <p>//from w  ww  .j  a  v a  2 s  . c  o  m
 * Given error message is displayed if file not found.
 * <p>
 * 
 * @param configFileName
 *          - File name of properties file.
 * @throws RuntimeException
 *           - If the file has a error while reading the properties file
 */
public static void loadProperties(String configFileName) {
    Properties cmdlineProps = System.getProperties();
    Properties fileProps = new Properties();

    // load property file
    InputStream inputStream = SystemPropsUtil.class.getResourceAsStream(configFileName);
    if (inputStream == null) {
        // force use of classloader to look for properties file
        inputStream = SystemPropsUtil.class.getClassLoader().getResourceAsStream(configFileName);
        if (inputStream == null) {
            log.warn(String.format("Failed to locate and load properties file: %s", configFileName));
            return;
        }
    } else {
        log.info("Properties file ({}) exists", configFileName);
    }

    // load fileProps with config.properties
    try {
        fileProps.load(inputStream);
    } catch (IOException e) {
        throw new RuntimeException(
                String.format("Failure occurred while reading properties file: %s", configFileName), e);
    }

    // Override any fileProp with cmdlineProps
    fileProps.putAll(cmdlineProps);
    System.setProperties(fileProps);
}

From source file:com.obidea.semantika.database.connection.ConnectionProviderFactory.java

public static Properties getConnectionProperties(PropertiesConfiguration properties) {
    Properties toReturn = new Properties();
    Iterator<String> iter = properties.getKeys();
    while (iter.hasNext()) {
        String propKey = iter.next();
        if (propKey.contains(Environment.CONNECTION_PREFIX)) {
            toReturn.setProperty(propKey, properties.getString(propKey));
        }/*from ww  w.  j  a  va  2  s  .  c  o  m*/
    }
    return toReturn;
}

From source file:de.highbyte_le.weberknecht.Version.java

@SuppressWarnings("nls")
public static synchronized Version getAppVersion() {
    if (null == appVersion) {
        try {// w ww.j a v a 2 s  .co  m
            InputStream in = Version.class.getResourceAsStream("version.properties"); //$NON-NLS-1$
            if (in != null) {
                try {
                    Properties p = new Properties();
                    p.load(in);

                    appVersion = parseProperties(p);
                } finally {
                    in.close();
                }
            } else {
                logger.error("getAppVersion() - version.properties not found");
            }
        } catch (IOException e) {
            logger.error("getAppVersion() - I/O Exception while loading version.properties: " + e.getMessage());
        }
    }

    return appVersion;
}

From source file:com.linkedin.pinot.common.utils.KafkaStarterUtils.java

public static Properties getDefaultKafkaConfiguration() {
    final Properties configuration = new Properties();

    // Enable topic deletion by default for integration tests
    configureTopicDeletion(configuration, true);

    // Set host name
    configureHostName(configuration, "localhost");

    return configuration;
}