?? propertyoperate.java
字號:
/*
* 創建日期 2005-9-21
*
* TODO 要更改此生成的文件的模板,請轉至
* 窗口 - 首選項 - Java - 代碼樣式 - 代碼模板
*/
package cn.itcareers.lxh.exercise.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
/**
* @author 白濤
*
* TODO 要更改此生成的類型注釋的模板,請轉至 窗口 - 首選項 - Java - 代碼樣式 - 代碼模板
*/
public class PropertyOperate {
/**
* 初始化時讀取屬性文件
* @return 屬性文件的Properties類型的實例化對象
*/
public Properties load() {
File f = new File("person.properties");
Properties pro = new Properties();
if (!f.exists()) {
pro = this.createProperty(f);
} else {
try {
pro.load(new FileInputStream(f));
} catch (FileNotFoundException e) {
// TODO 自動生成 catch 塊
e.printStackTrace();
} catch (IOException e) {
// TODO 自動生成 catch 塊
e.printStackTrace();
}
}
return pro;
}
/**
* 創建屬性文件
* @param f 要操作的文件類
* @return Properties實例化對象
*/
private Properties createProperty(File f) {
Properties pro = new Properties();
pro.put("student", "cn.itcareers.lxh.exercise.person.Student");
pro.put("worker", "cn.itcareers.lxh.exercise.person.Worker");
try {
pro.store(new FileOutputStream(f), "Person INFO");
} catch (FileNotFoundException e) {
// TODO 自動生成 catch 塊
e.printStackTrace();
} catch (IOException e) {
// TODO 自動生成 catch 塊
e.printStackTrace();
}
return pro ;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -