?? classidentity.java
字號:
/*
* 創(chuàng)建日期 2005-11-3
*
* TODO 要更改此生成的文件的模板,請轉(zhuǎn)至
* 窗口 - 首選項 - Java - 代碼樣式 - 代碼模板
*/
package databaseConnectPool;
/**
* @author Administrator
*
* TODO 要更改此生成的類型注釋的模板,請轉(zhuǎn)至
* 窗口 - 首選項 - Java - 代碼樣式 - 代碼模板
*/
import java.util.*;
import java.io.*;
public class ClassIdentity {
private Hashtable ClassHash;
private File ClassFile;
private FileReader classFileReader; //讀文件對象
private int TMP_BUFFER_SIZE = 30;
/**
* @roseuid 3D9BB9390108
*/
public ClassIdentity(java.io.File ClassFile) {
System.out.println("[INFOR]類型種別碼表已創(chuàng)建!");
this.ClassFile = ClassFile;
}
/**
* @roseuid 3D9BB0B40383
*/
//查找類型種別碼
public int findKey(String classWord) {
int KEY;
for (Enumeration e = this.ClassHash.keys(); e.hasMoreElements(); ) {
KEY = Integer.parseInt( (String) e.nextElement());
if ( ( (String)this.ClassHash.get(Integer.toString(KEY))).
equalsIgnoreCase(classWord)) {
return KEY;
}
}
return -1;
}
/**
* @roseuid 3D9BAE7303D3
*/
public void initClassIdentityTable() {
ClassHash = new Hashtable(); //創(chuàng)建hash表
int intLength;
char[] chrBuffer = new char[TMP_BUFFER_SIZE];
String classWord;
int classCounter = 0;
try {
if (ClassFile.exists()) { //文件存在
//創(chuàng)建讀文件對象
classFileReader = new java.io.FileReader(ClassFile);
//讀文件內(nèi)容到hash表
while ( (intLength = classFileReader.read(chrBuffer)) != -1) {
classCounter++;
//填寫hash表
classWord = String.valueOf(chrBuffer).trim();
System.out.println("[INFOR]讀取類型種別碼: [KEY: " + classCounter +
"][VALUE: " + classWord + "]");
this.ClassHash.put(Integer.toString(classCounter), classWord);
}
//關(guān)閉讀文件對象
classFileReader.close();
}
else { //文件不存在
System.err.println("[ERROR]類型種別碼文件不存在!");
}
}
catch (Exception e) {
e.printStackTrace(System.err);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -