어디선가 베껴왔음
package com.zeroidle.trinity;
import java.util.Properties;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class Configuration {
private String PROPERTIES_FILE = “conf/config.conf”;
private String getProperty(String key) {
String value = “”;
try {
Properties props = new Properties();
FileInputStream fis =
new FileInputStream(PROPERTIES_FILE);
props.load(fis);
value = props.getProperty(key);
fis.close();
} catch (java.lang.Exception e) {
e.printStackTrace();
}
return value;
}
private void setProperty(String key, String value) {
try {
Properties props = new Properties();
FileInputStream fis =
new FileInputStream(PROPERTIES_FILE);
props.load(fis);
props.setProperty(key, value);
//2번째인자(“”)는 프로퍼티파일의 첫번째줄에 코멘트로저장
props.store(new FileOutputStream(PROPERTIES_FILE), “”);
fis.close();
} catch(java.lang.Exception e) {
System.out.println(e.toString());
}
}
public static void main(String[] args) {
System.out.println(“하이”);
Configuration conf = new Configuration();
System.out.println(conf.getProperty(“dbHost”));
}
}