Feeds:
Posts
Comments

Archive for March, 2018

ssh-keyscan -H remote-host-domain-or-ip >> ~/.ssh/known_hosts

Read Full Post »

public class MyConfig {

public static Properties appProperties() throws IOException {

//method 1: in application configuration, the configuration file my-config.properties is in src/main/resources

//refer to https://stackoverflow.com/questions/2161054/where-to-place-and-how-to-read-configuration-resource-files-in-servlet-based-app

ClassLoader classLoader = Thread.currentThread().getContextClassLoader();

InputStream inStream = classLoader.getResourceAsStream(“ngs16s-config.properties”);

Properties properties = new Properties();

properties.load(inStream);

//method 2: in container configuration, the configuration file my-config.properties is in $WILDFLY_HOME/standalone/configuration
//https://stackoverflow.com/questions/27953261/wildfly-reading-properties-from-configuration-directory

String fileName = System.getProperty(“jboss.server.config.dir”) + “/my-config.properties”;

Properties properties = new Properties();

FileInputStream fis = new FileInputStream(fileName);

properties.load(fis);

}

}

my-config.properties file has key-value pairs separated by tab, such as
my_property_name  my_property_value

How to use it:

String myProperty = MyConfig.appProperties().getProperty(“my_property_name”)

Read Full Post »