大二用java开发的一个不用数据库支持的通讯录
在大二第一学期的时候,在学习了JAVA中的输入输出流后老师要我们做一个通讯录。其功能可以添加删除和在关闭时保存信息,保存和导入数据用的技术是纯粹的IO流,没有设计到数据库,呵呵,功能是实现出来了,但效率可能不怎么好,希望高手们看完后给小弟点意见,我会改进的,OK,以下是我的原代码和试用方法说明:
代码:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import javax.swing.border.*;
import java.util.*;
class People implements Serializable
{
static int j;
static int j2=0;
static int j3=0;
static int munber=0; //这个就是整个程序的计数器
private static final long serialVersionUID = 3757263881374182471L;
String ID;
String Name;
String Address;
String Phone;
String Work;
protected Object length;
People(String ID,String Name,String Address,String Phone,String Work)
{
this.ID=ID;
this.Name=Name;
this.Address=Address;
this.Phone=Phone;
this.Work=Work;
}
String getID()
{
return ID;
}
String getName()
{
return Name;
}
String getAddress()
{
return Phone;
}
String getWork()
{
return Work;
}
static public String id()//变数据为字符
{
int jj=j;
Integer id=new Integer(2);
id=jj;
String iD=id.toString();
return iD;
}
static public String id2()//添加自加功能的方法,显示在文本框上
{
int j1=j+1;
Integer id2=new Integer(1);
id2=j1;
String jd=id2.toString();
return jd;
}
public String getValue()
{
String value="ID号:"+ this.ID+" "+"姓名:"+this.Name+" "+"地址:"+this.Address+" "+"电话:"+this.Phone+" "+"单位:"+this.Work+'\n';
return value;
}
}
public class tongxunlu extends JFrame
{
private static final long serialVersionUID = 1057782438609006743L;
//初始化窗口实现类
JTextField ID;
JTextField Name;
JTextField Address;
JTextField Phone;
JTextField Work;
JTextField IDc;
JTextField Namec;
JTextField Addressc;
JTextField Phonec;
JTextField Workc;
JButton Add;
JButton Clear;
JButton Load;
JButton Save;
JButton Delect;
JButton Check;
JPanel P1;
JPanel P2;
JTextArea Show;
JTextArea Show2;
JTabbedPane p;
Box baseBox,baseBox2,boxV1,boxV2,boxV3,boxV4,boxV5;
FileOutputStream fileOut;
ObjectOutputStream objectOut;
FileInputStream fileIn;
ObjectInputStream objectIn;
FileOutputStream fileOut2;
FileInputStream fileIn2;
DataInputStream dataInput;
DataOutputStream dataOutput;
FileWriter out;
FileReader in;
People p1[]=new People[100]; //构造存储数组
People personLoad[]=new People[100];
People personSave[]=new People[100];
People person[]=new People[100]; //定义person为保存对象的数组,容量是100个对象
tongxunlu (String s)
{ super(s); &