Property 程式庫
piProperty 程式庫
package com.PowerIntegral;
/**
* <p>Title: piProperty</p>
*
* <p>Description: piProperty</p>
*/
public class piProperty {
private String _ErrorMessage = "";
private boolean _OK = false;
/**
* piProperty: 建構子
*/
public piProperty() {
}
/**
* Load: 載入定義檔
*
* @param MyProperties Properties => 定義物件
* @param PropertyFile String => 定義檔
* @return boolean
*/
public boolean Load(java.util.Properties MyProperties, String PropertyFile) {
this._OK = false;
this._ErrorMessage = "";
if (MyProperties == null) {
this._ErrorMessage = "Illegal Parameter";
return this._OK;
}
try {
java.io.File _File = new java.io.File(PropertyFile);
java.io.FileInputStream _FileInputStream = new java.io.
FileInputStream(_File);
MyProperties.load(_FileInputStream);
_FileInputStream.close();
this._OK = true;
} catch (Exception ex) {
this._OK = false;
this._ErrorMessage = ex.getMessage();
}
return this._OK;
}
/**
* getPropertyValue: 取出定義
*
* @param Props Properties => 定義物件
* @param KeyName String => 索引鍵
* @param Charset String => 定義值
* @return String
*/
public String getPropertyValue(java.util.Properties MyProperties, String KeyName,
String Charset) {
String _KeyValue_ISO8859_1 = "", _KeyValue_Big5 = "";
this._OK = false;
this._ErrorMessage = "";
try {
_KeyValue_ISO8859_1 = MyProperties.getProperty(KeyName);
_KeyValue_Big5 = new String(_KeyValue_ISO8859_1.getBytes(
"iso8859-1"), Charset);
} catch (Exception ex) {
this._ErrorMessage = ex.getMessage();
}
return _KeyValue_Big5;
}
/**
* getErrorMessage: 取出最近執行錯誤訊息
*
* @return String
*/
public String getErrorMessage() {
return this._ErrorMessage;
}
/**
* getSuccess: 取出最近執行狀態
*
* @return boolean
*/
public boolean getSuccess() {
return this._OK;
}
}