java configuration
package com.sophon.search;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
* Created by yinchunxiang on 05/06/2017.
*/
public class Config {
private Properties props = new Properties();
//public Config() {}
public boolean init(String file) {
try {
//InputStream in = Config.class.getResourceAsStream("search/config.properties");
System.out.println("file => " + file);
InputStream in = Config.class.getResourceAsStream(file);
if (null == in) {
System.out.println("input stream is null");
return false;
}
this.props.load(in);
in.close();
return true;
}catch (IOException e) {
System.out.println(e.toString());
return false;
}
}
public String get(String key) {
return this.props.getProperty(key);
}
}