一个Property文件封装类
PropertyFile.java
package tools;
import ……
/**
* 功能:工具函数,封装对属性文件的操作
* @author LOVO
*/
public class PropertyFile {
//私有属性成员
private Properties prop;
private String fileName;
//初始化:指定文件名
public PropertyFile(String _fileName){
prop = new Properties();
this.fileName = _fileName;
load();
}
//读取文件到内存
public void load(){
prop.load(new FileInputStream(this.fileName));
}
//保存文件到磁盘中
public boolean save(){
prop.store(new FileOutputStream(this.fileName),null);
}
//读取鍵值
public String getKeyValue(String _key){
String value = prop.getProperty(_key);
}
//设置鍵值
public void setKeyValue(String _key,String _value){
prop.setProperty(_key, _value);
}
}
SystemInput.java核心代码 BufferedReader bf = new BufferedReader( new InputStreamReader(System.in));
String data = bf.readLine();