📄 readtel.java
字号:
/*
* Tel.java
*
* Created on 2006年4月14日, 上午11:24
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package hello;
import java.io.*;
import java.util.Vector;
/**
*
* @author dyzq
*/
public class ReadTel {
public String[][] hm;
public boolean fshm[];
public String xzfs[] ;
public boolean sarry[] ;
public int hmcd = 0;
/** Creates a new instance of Tel */
public ReadTel() {
Vector vg;
//读取组信息
vg = readGroup();
xzfs = new String[vg.size()];
sarry = new boolean[xzfs.length];
//将组的数据赋值到数据中
for(int i=0;i<vg.size();i++){
xzfs[i] = (String)vg.elementAt(i);
}
//读取电话信息
vg = readTel();
hm = new String[vg.size()/3][3];
fshm = new boolean[hm.length];
hmcd = Integer.toString(hm.length).length();
for(int i=0;i<vg.size()/3;i++){
hm[i][0] = (String)vg.elementAt(i*3);
hm[i][1] = (String)vg.elementAt(i*3+1);
hm[i][2] = (String)vg.elementAt(i*3+2);
}
// for(int i=0;i<hm.length;i++){
// System.out.println("=============");
// System.out.println(hm[i][0].length());
// System.out.println(hm[i][0]);
// System.out.println(hm[i][1]);
// System.out.println(hm[i][2]);
// }
}
public Vector readGroup(){
int ch = 0;
Vector vg = new Vector();
String sg = "";
InputStream is = getClass().getResourceAsStream("group.txt");
InputStreamReader isr = null;
try {
isr = new InputStreamReader(is,"UTF-8");
} catch (UnsupportedEncodingException ex) {
ex.printStackTrace();
}
StringBuffer sb=new StringBuffer();
try {
while((ch= isr.read()) != -1) {
if(ch != 0) {
sb.append((char)ch);
}
}
} catch (IOException ex) {
ex.printStackTrace();
}
try {
is.close();
} catch (IOException ex) {
ex.printStackTrace();
}
for(int i=1;i<sb.length();i++){
ch = sb.charAt(i);
//System.out.println(Integer.toHexString(ch));
if(ch == 13 && sb.charAt(i+1) == 10){
if(!sg.equals("")){
vg.addElement(sg);
}
// System.out.println("===========");
// System.out.println(sg);
sg = "";
i++;
}else{
sg += (char)ch;
}
}
return vg;
}
public Vector readTel(){
int ch = 0;
Vector vg = new Vector();
String sg = "";
String stemp = "";
int douhao1,douhao2;
InputStream is = getClass().getResourceAsStream("tel.txt");
InputStreamReader isr = null;
try {
isr = new InputStreamReader(is,"UTF-8");
} catch (UnsupportedEncodingException ex) {
ex.printStackTrace();
}
StringBuffer sb=new StringBuffer();
try {
while((ch= isr.read()) != -1) {
if(ch != 0) {
sb.append((char)ch);
}
}
} catch (IOException ex) {
ex.printStackTrace();
}
try {
is.close();
} catch (IOException ex) {
ex.printStackTrace();
}
for(int i=1;i<sb.length();i++){
ch = sb.charAt(i);
//System.out.println(Integer.toHexString(ch));
if(ch == 13 && sb.charAt(i+1) == 10){
if(!sg.equals("")){
//取电话号码
douhao2 = sg.indexOf(",",0);
stemp = sg.substring(0,douhao2);
douhao1 = douhao2 + 1;
vg.addElement(stemp);
// System.out.println("===========");
// System.out.println(stemp);
//取组信息
douhao2 = sg.indexOf(",",douhao1);
stemp = sg.substring(douhao1,douhao2);
douhao1 = douhao2 + 1;
vg.addElement(stemp);
// System.out.println("===========");
// System.out.println(stemp);
//取姓名
stemp = sg.substring(douhao1);
vg.addElement(stemp);
// System.out.println("===========");
// System.out.println(stemp);
}
sg = "";
i++;
}else{
sg += (char)ch;
}
}
return vg;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -