📄 baseconfigration.java
字号:
package com.dc.config;
/*
* Created on 2008/07/21
*
* Copyright Cluck.
* All right reserved.
*/
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;
public class BaseConfigration {
/**
* 创建Properties
*/
private Properties configration = new Properties();
/**
* 最后修改时间
*/
private long modifyDate = 0;
/**
* .properties 文件名
*/
private String fileName = null;
/**
* BaseConfigration构造函数
*
*/
public BaseConfigration() {
}
/**
* 获取属性值
* @param key 指定的键
* @return 属性值
*/
public String getMessage(String key) {
config();
String message = configration.getProperty(key);
return message;
}
/**
* 获取属性列表和对应的键值
*
*/
private void config() {
File file = new File(fileName);
long lastModify = file.lastModified();
if (lastModify > modifyDate) {
modifyDate = lastModify;
try {
FileInputStream fileInputStream = new FileInputStream(file);
BufferedInputStream bInputStream = new BufferedInputStream(
fileInputStream);
configration.load(bInputStream);
bInputStream.close();
fileInputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* 获取fileName
* @return fileNames
*/
public String getFileName() {
return fileName;
}
/**
* 设置fileName
* @param fileName fileName
*/
public void setFileName(String fileName) {
this.fileName = fileName;
}
public Properties getProperties() {
config();
return configration;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -