Java Properties Load from File loadPropertiesFromFile(String configFile)

Here you can find the source of loadPropertiesFromFile(String configFile)

Description

load Properties From File

License

Open Source License

Declaration

private static InputStream loadPropertiesFromFile(String configFile)
            throws FileNotFoundException, IOException 

Method Source Code

//package com.java2s;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

import java.io.IOException;
import java.io.InputStream;

import java.util.Properties;

public class Main {
    private static final String DEFAULT_SERVER = "127.0.0.1";
    private static final String DEFAULT_BASE = "RASBASE";
    private static final String DEFAULT_PORT = "7001";
    private static final String DEFAULT_USER = "rasguest";
    private static final String DEFAULT_PASSWD = "rasguest";
    private static final String DEFAULT_ADMIN_USER = "rasadmin";
    private static final String DEFAULT_ADMIN_PASSWD = "rasadmin";
    private static String server;
    private static String database;
    private static String port;
    public static String username;
    public static String password;
    public static String adminUsername;
    public static String adminPassword;

    private static InputStream loadPropertiesFromFile(String configFile)
            throws FileNotFoundException, IOException {
        final InputStream input = new FileInputStream(configFile);
        final Properties prop = new Properties();
        prop.load(input);//from w ww  .  ja  va2s  .com

        server = prop.getProperty("ras.server", DEFAULT_SERVER);
        database = prop.getProperty("ras.database", DEFAULT_BASE);
        port = prop.getProperty("ras.port", DEFAULT_PORT);
        username = prop.getProperty("ras.username", DEFAULT_USER);
        password = prop.getProperty("ras.password", DEFAULT_PASSWD);
        adminUsername = prop.getProperty("ras.admin.username",
                DEFAULT_ADMIN_USER);
        adminPassword = prop.getProperty("ras.admin.password",
                DEFAULT_ADMIN_PASSWD);
        return input;
    }
}

Related

  1. loadPropertiesFromClasspath( final String filename)
  2. loadPropertiesFromClasspath(Class loadResourceClass, String classpath)
  3. loadPropertiesFromClasspath(String pfname)
  4. loadPropertiesFromFile(Class clazz, String filePath)
  5. loadPropertiesFromFile(JarFile jar)
  6. loadPropertiesFromFile(String filePath)
  7. loadPropertiesFromFile(String fullFileName)
  8. loadPropertiesFromFile(String pathname)
  9. loadPropertiesFromPath(String propsFilePath)