Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! [Re:Alerander]
Alerander





发贴: 8
积分: 0
于 2004-09-06 11:31 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
import java.io.*;
class OneDeposit{
String[] info=new String[9]; //声明存储储户信息的数组
OneDeposit(){}
public OneDeposit(String number,String name,String password,String capital,
String sort,String saveDay,String address,String saveAssistant,String isLost){
info[0]=number; info[1]=name; info[2]=password;
info[3]=capital; info[4]=sort; info[5]=saveDay;
info[6]=address; info[7]=saveAssistant; info[8]=isLost;
}
void createFiles()throws IOException{
File f=new File("存款文件.dat");
if(!f.exists()){
BufferedWriter out=new BufferedWriter(new FileWriter("存款文件.dat"));
out.close();
}
}
void write(BufferedWriter out)throws IOException{
for(int i=0;i<9;i++){
out.write(this.info[i]);
out.newLine();
}
}
int search(BufferedReader in,String number)throws IOException{
int line=0,i;
while(in.readLine()!=null){line++;}
String[][] info2=new String[line/9][9];
for(int a=0;a<info2.length;a++){
for(int b=0;b<info2[a].length;b++){
info2[a]=in.readLine();
}
}
//测试区
for(int c=0;c<info2.length;c++){
  for(int d=0;d<info2[c].length;d++){System.out.println(info2[c][d]);}
}
for(i=0;i<info2.length;i++){
if(info2[i].equals(number)) {
for(int j=0;j<9;j++){info[j]=info2[i][j];}
return 1;
}
}
return -1;
}
}
public class TestOneDeposit{
public static void main(String[] args){
OneDeposit d1=new OneDeposit();
d1.info[0]="19860923";
d1.info[1]="李四";
d1.info[2]="abcdef";d1.info[3]="65300";d1.info[4]="三年";
d1.info[5]="20041001";d1.info[6]="中华人民共和国";
d1.info[7]="混蛋007";d1.info[8]="false";
for(int j=0;j<9;j++){System.out.println(d1.info[j]+" ");}
try{
BufferedWriter out=new BufferedWriter(new FileWriter("存款文件.dat",true));
d1.write(out);
}catch(IOException el){System.out.println(el);}
try{
BufferedReader in=new BufferedReader(new FileReader("存款文件.dat"));
OneDeposit d2=new OneDeposit();
int k=d2.search(in,"19860923");
for(int j=0;j<9;j++){System.out.println(d2.info[j]+" ");}
}catch(IOException e){}
}
}


又试着写了一个这样的程序,还是没用啊~~~~急噪咯!


why edited on 2004-09-06 11:34


话题树型展开
人气 标题 作者 字数 发贴时间
5990 谁能帮我看看这个类,为什么read()方法没有用啊?!! Alerander 2365 2004-09-06 09:24
5032 Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! why 224 2004-09-06 09:41
5092 Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! Alerander 49 2004-09-06 10:27
4988 Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! why 112 2004-09-06 11:03
5081 Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! Alerander 41 2004-09-06 11:10
5032 Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! why 292 2004-09-06 11:13
5149 Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! Alerander 654 2004-09-06 11:25
4948 Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! why 208 2004-09-06 11:29
5053 Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! Alerander 48 2004-09-06 11:26
5124 Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! Alerander 2347 2004-09-06 11:31
5157 Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! Alerander 1046 2004-09-06 11:34
5166 Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! Alerander 24 2004-09-06 11:41

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923