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

/**
 * Loads properties by given file/*from www  . j  a  v a 2  s . c  o  m*/
 * 
 * @param file
 *            filename
 * @return loaded properties
 * @throws java.io.IOException
 *             if can't load file
 */
public static Properties load(File file) throws IOException {

    FileInputStream fis = new FileInputStream(file);
    Properties p = new Properties();
    p.load(fis);
    fis.close();
    return p;
}

From source file:org.fingerprintsoft.vitunit.test.VitUnitTestCase.java

protected static DataSource loadDatasource(final Class<? extends VitUnitTestCase> clazz) {

    DataSourceConfiguration annotation = clazz.getAnnotation(DataSourceConfiguration.class);

    String jdbcPropertiesFile = annotation.jdbcPropertiesFile();
    InputStream resourceAsStream = clazz.getClassLoader().getResourceAsStream(jdbcPropertiesFile);
    Properties properties = new Properties();
    try {/*  w ww  .  ja  va 2  s .  c o  m*/
        properties.load(resourceAsStream);
    } catch (IOException e) {
        throw new SetupException("Could not load properties.", e);
    }

    try {
        return BasicDataSourceFactory.createDataSource(properties);
    } catch (Exception e) {
        throw new SetupException("Could not create datasource.", e);
    }
}

From source file:com.qubole.quark.planner.test.PartialCubeTest.java

protected static SqlQueryParser getParser(String filter) throws JsonProcessingException, QuarkException {
    Properties info = new Properties();
    info.put("unitTestMode", "true");
    info.put("schemaFactory", "com.qubole.quark.planner.test.PartialCubeSchemaFactory");

    ImmutableList<String> defaultSchema = ImmutableList.of("TPCDS");
    final ObjectMapper mapper = new ObjectMapper();

    info.put("defaultSchema", mapper.writeValueAsString(defaultSchema));
    info.put("filter", filter);
    return new SqlQueryParser(info);
}

From source file:com.mirth.connect.model.converters.tests.NCPDPSerializerTest.java

@Before
public void setUp() throws Exception {
    defaultProperties = new Properties();
    defaultProperties.put("segmentDelimiter", "0x1E");
    defaultProperties.put("groupDelimiter", "0x1D");
    defaultProperties.put("fieldDelimiter", "0x1C");
    defaultProperties.put("useStrictValidation", "false");
}

From source file:eu.vital.maps.server.servlets.EventsConsumer.java

private static ConsumerConfig createConsumerConfig() {
    Properties props = new Properties();
    props.put("zookeeper.connect", "localhost:2181");
    props.put("group.id", "test");
    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:ch.algotrader.config.spring.ConfigLoader.java

static void loadResource(final Map<String, String> paramMap, final Resource resource) throws IOException {

    try (InputStream inputStream = resource.getInputStream()) {
        Properties props = new Properties();
        props.load(new InputStreamReader(inputStream, StandardCharsets.UTF_8));

        for (Map.Entry<Object, Object> entry : props.entrySet()) {
            String paramName = (String) entry.getKey();
            String paramValue = (String) entry.getValue();
            if (StringUtils.isNotBlank(paramName)) {
                paramMap.put(paramName, paramValue);
            }/* w ww  .j  av  a  2 s  .c  o  m*/
        }

    }
}

From source file:com.webkruscht.wmt.DownloadFiles.java

private static void getProperties() throws IOException {
    Properties p = new Properties();
    String propFile = "wmt.properties";
    InputStream propStream = DownloadFiles.class.getClassLoader().getResourceAsStream(propFile);
    p.load(propStream);//  w w  w . ja  va 2  s. c o m
    propStream.close();
    username = p.getProperty("username");
    password = p.getProperty("password");
    filePath = p.getProperty("filePath");
}

From source file:ezbake.security.persistence.impl.FileRegManagerTest.java

private static FileRegManager setUpManager(File testFile) {
    Properties properties = new Properties();
    properties.put(FileRegManager.REGISTRATION_FILE_PATH, testFile.getAbsolutePath());
    return new FileRegManager(properties);
}

From source file:com.aionemu.commons.utils.PropertiesUtils.java

/**
 * Loads properties by given file/*from w w  w  .ja v a2s  .c  om*/
 *
 * @param file filename
 * @return loaded properties
 * @throws java.io.IOException if can't load file
 */
public static Properties load(File file) throws IOException {
    FileInputStream fis = new FileInputStream(file);
    Properties p = new Properties();
    p.load(fis);
    fis.close();
    return p;
}

From source file:eu.learnpad.simulator.mon.utils.Manager.java

@SuppressWarnings("deprecation")
public static Properties Read(String fileName) {
    Properties readedProps = new Properties();

    File file = new File(fileName);
    FileInputStream fis = null;/*www .j av a2  s  .  co  m*/
    BufferedInputStream bis = null;
    DataInputStream dis = null;

    try {
        fis = new FileInputStream(file);

        // Here BufferedInputStream is added for fast reading.
        bis = new BufferedInputStream(fis);
        dis = new DataInputStream(bis);

        // dis.available() returns 0 if the file does not have more lines.
        String property = "";
        String key = "";
        String value = "";

        while (dis.available() != 0) {
            // this statement reads the line from the file and print it to
            // the console.
            property = dis.readLine().trim();
            if (property.length() > 0) {
                key = property.substring(0, property.indexOf("="));
                value = property.substring(property.indexOf("=") + 1, property.length());

                readedProps.put(key.trim(), value.trim());
            }
        }

        // dispose all the resources after using them.
        fis.close();
        bis.close();
        dis.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return readedProps;
}