📄 jmpropertycatch.java
字号:
package jm.util;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;
import java.util.ResourceBundle;
/**
* JMProPertyCatch
* @author fu_changyong(1shome)
* @see jdk1.5.2
* @version 1.5.2.2
*/
public class JMProPertyCatch {
public static final String CLASS_NAME = "JMProPertyCatch";
private String filename = null;
private Properties props = new Properties();
private final String PATH = "/";
public JMProPertyCatch (String fileName) {
filename = fileName;
}
public void loadProperties () throws Exception {
try {
props.load(getClass().getResourceAsStream(PATH + filename + ".properties"));
} catch (Exception e) {
throw e;
}
}
public void loadXML () throws Exception {
try {
props.loadFromXML(new FileInputStream(PATH + filename + ".xml"));
} catch (Exception e) {
throw e;
}
}
public void setFileName (String fileName) {
filename = fileName;
}
public String getFileName () {
return filename;
}
public String getProperty (String key) throws Exception {
try {
return props.getProperty(key);
} catch (Exception e) {
throw e;
}
}
public void setProperty (String key, String val) throws Exception {
try {
props.setProperty(key, val);
} catch (Exception e) {
throw e;
}
}
public void storeProperties (String Titles) throws Exception {
try {
props.store(new FileOutputStream(filename + ".properties"), Titles);
} catch (Exception e) {
throw e;
}
}
public void storeXML (String Titles) throws Exception {
try {
props.storeToXML(new FileOutputStream(filename + ".xml"), Titles);
} catch (Exception e) {
throw e;
}
}
public static String getProperties (String filename, String key) {
ResourceBundle res = ResourceBundle.getBundle(filename);
return res.getString(key);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -