?? workflow_tools.java
字號:
package treedoc;
//工具類.從電子政務(wù)取過來,目前沒有使用
/**
* 名稱 : WORKFLOW_TOOLS
* 描述 : WWW.FANGFA.NET 工作流管理系統(tǒng)--工具類
* 版權(quán)信息 : Copyright (c) 2004 COMSCI
* @作者 : COMSCI Sichuan Fangfa Digital
* @版本 : 0.9 builder 2004091910
* @日期 : 2004/09/19
*/
import java.io.UnsupportedEncodingException;
import java.util.Vector;
public class workflow_tools {
public workflow_tools() {
}
/**
* 功能: 將漢字轉(zhuǎn)換成unicode
* @param str 需要轉(zhuǎn)換的漢字
* @return 轉(zhuǎn)換后的unicode字符
*/
public String chineseToUnicode(String str) {
String newstring = null;
try {
if (str == null || str.equals("")) {
return "";
}
newstring = new String(str.getBytes("GB2312"), "ISO-8859-1");
}
catch (UnsupportedEncodingException ex) {
System.out.println(
"<<<<<<<<<<< there is something wrong with the JavaBean method ! >>>>>>>>>>>>>>");
ex.printStackTrace();
}
return newstring;
}
/**
* 功能: 將unicode轉(zhuǎn)換成漢字
* @param str 需要轉(zhuǎn)換的unicode字符
* @return 轉(zhuǎn)換后的漢字
*/
public String unicodeToChinese(String str) {
String newstring = null;
try {
if (str == null || str.equals("")) {
return "";
}
newstring = new String(str.getBytes("ISO-8859-1"), "GB2312");
}
catch (UnsupportedEncodingException ex) {
System.out.println(
"<<<<<<<<<<< there is something wrong with the JavaBean method ! >>>>>>>>>>>>>>");
ex.printStackTrace();
}
return newstring;
}
/**
* 功能:判斷字符串是否為只包括字母和數(shù)字
* @param validString 需要判斷處理的字符串
* @return 如果只包含字母和數(shù)字則返回true,否則返回false
*/
public boolean isChar(String validString) {
byte[] tempbyte = validString.getBytes();
for (int i = 0; i < validString.length(); i++) {
if ( (tempbyte[i] < 48) || ( (tempbyte[i] > 57) & (tempbyte[i] < 65)) ||
(tempbyte[i] > 122) || ( (tempbyte[i] > 90) & (tempbyte[i] < 97))) {
return false;
}
}
return true;
}
/**
* 功能:把傳入的double類型數(shù)據(jù)轉(zhuǎn)換規(guī)定的包含幾位小數(shù)的double類型數(shù)據(jù)
* @param sourceNum 源數(shù)據(jù)
* @param length 準(zhǔn)備取小數(shù)點(diǎn)后幾位數(shù)
* @return 返回的數(shù)據(jù)
*/
public double getSpecialPosition(double sourceNum, int length) {
String tempStr = Double.toString(sourceNum);
int tempLen = length;
int dotPosition = tempStr.indexOf(".");
int dot = dotPosition + 1 + tempLen;
String resultStr = tempStr.substring(0, dot);
double result = Double.valueOf(resultStr).doubleValue();
return result;
}
/**
* 功能:將輸入的字符串按照某種要求的分隔符分隔開,形成一個不包含分隔符的數(shù)組
* @param sourceStr 想要分隔的字符串
* @param symbol 分隔符
* @return 分隔好后不包含分隔符的字符串?dāng)?shù)組
*/
public String[] split(String sourceStr, String symbol) {
String[] returnStr;
int index = 0;
String tempStr = sourceStr;
int subLength = symbol.length();
Vector v = new Vector();
while (true) {
index = tempStr.indexOf(symbol);
if (index == -1) {
break;
}
v.add(tempStr.substring(0, index));
tempStr = tempStr.substring(index + subLength);
}
if (tempStr.length() != 0) {
v.add(tempStr);
}
if (v.size() > 0 && ( (String) v.get(0)).length() == 0) {
v.remove(0);
}
returnStr = new String[v.size()];
for (int i = 0; i < v.size(); i++) {
returnStr[i] = (String) v.get(i);
}
return returnStr;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -