Last active
June 20, 2017 11:25
-
-
Save yinchunxiang/bc795abbb3a6d09ba39a1b87125f6c92 to your computer and use it in GitHub Desktop.
java configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment