📄 readproperty.java
字号:
package com.code10.access;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;
public class ReadProperty {
private static ReadProperty instance = null;
Properties prop= null;
String fileName;
private ReadProperty(){
fileName="/config.property";
prop= new Properties();
try {
InputStream is = getClass().getResourceAsStream(fileName);
prop.load(is);
if(is!=null) is.close();
}
catch(Exception e) {
System.out.println(e+"file "+fileName+" not found");
}
}
public static synchronized ReadProperty newInstance()
{
if(instance==null)
instance=new ReadProperty();
return instance;
}
public String getPara(String name) {
return prop.getProperty(name);
}
public void setPara(String name,String value){
try {
OutputStream fos = new FileOutputStream("config.property");
prop.setProperty(name,value);
prop.store(fos, null);
fos.flush();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e){
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -