Topic: 谁能帮我看看这个类,为什么read()方法没有用啊?!! |
Print this page |
1.谁能帮我看看这个类,为什么read()方法没有用啊?!! | Copy to clipboard |
Posted by: Alerander Posted on: 2004-09-06 09:24 /*以下是储户信息类OneDeposit,用来保存储户信息以及对储户信息进行 这个类的read()方法是为了查找一个跟saveNumber一致的储户的信息,但是却读不出来整个信息,只有isLost被赋了值。有哪位大侠能帮我改一下啊,好急啊!!!!多谢多谢了! 我的QQ:241866421 再次谢谢! |
2.Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! [Re: Alerander] | Copy to clipboard |
Posted by: why Posted on: 2004-09-06 09:41 if(str==saveNumber) if (strr=="true") should be if (str.equals(saveNumber)) if (strr.equals("true")) check other String comparisons... and there could be other problems, not to mention the implementation, style, etc. |
3.Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! [Re: Alerander] | Copy to clipboard |
Posted by: Alerander Posted on: 2004-09-06 10:27 没有用啦,我试着输出几个成员变量的值,但是都是null 急啊~~~~~~~~~~~~~~~~~` |
4.Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! [Re: Alerander] | Copy to clipboard |
Posted by: why Posted on: 2004-09-06 11:03 虽然没有用,但这是明显的错误。 用 debugger 找不到错吗? 还是未用呢? 敝人没用过 RandomAccessFile,但 Random Access 不是要处理 file pointer 吗?看不见。 |
5.Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! [Re: Alerander] | Copy to clipboard |
Posted by: Alerander Posted on: 2004-09-06 11:10 没有啊 我还是初学者啊,那些错误都改了可还是没用 不知道哪位大哥能帮忙修改一下 |
6.Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! [Re: Alerander] | Copy to clipboard |
Posted by: why Posted on: 2004-09-06 11:13 Alerander wrote: 怎样修改? 多半要重写,哪岂非替阁下做家课? >> 敝人没用过 RandomAccessFile,但 Random Access 不是要处理 file pointer 吗?看不见。 到底有没有处理? 看来须要加上 in.seek(0); 从头开始读的。 阁下说“试着输出几个成员变量的值,但是都是null” 到底怎样试? 阁下还是先把调用这个 OneDeposit 类的咚咚都贴上来吧。 |
7.Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! [Re: Alerander] | Copy to clipboard |
Posted by: Alerander Posted on: 2004-09-06 11:25 这位大哥言重了,这是一个基础类,没有它根本谈不上调用它的类啊!这样吧,我把它的需求帖过来吧: 1.“储户信息”类 属性 账号,姓名,密码,地址,储种,本金,收储日期,是否已挂失及挂失日期,以及存款时营业员信息 服务 创建 接口:无返回值,参数为:姓名,密码,地址,储种,本金,收储 日期,是否已挂失及挂失日期,以及存款时营业员信息 功能:用给定的参数创建一个储户信息对象 创建存款文件 接口:无返回值,无参数 功能:检查是否存在存款文件,若不存在则创建之 读取存款信息 接口:参数为输入流对象“存款文件.dat”和String对象saveNumber 功能:从输入流读取账号为saveNumber的储户信息对象 写入储户信息 接口:无返回值,参数为输出流对象“存款文件.dat” 功能:将一个储户信息写到输出流中 删除储户信息 接口:无返回值,参数无 功能:删去该储户信息对象 表述上可能有点问题还请见谅!这个问题问了老师也解决不了,不得已烦劳各位高手,在下再次谢谢各位了! |
8.Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! [Re: Alerander] | Copy to clipboard |
Posted by: Alerander Posted on: 2004-09-06 11:26 对了~~ 如果改用成BufferedWriter和BufferedReader也可以的~~~~ |
9.Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! [Re: Alerander] | Copy to clipboard |
Posted by: why Posted on: 2004-09-06 11:29 Alerander wrote: 晕! 那么“输出几个成员变量的值,但是都是null” 这句话从何说起? 如果改用成BufferedWriter和BufferedReader也可以的~~~~ 哪裡改? 怎样改? 敝人不是阁下肚裡的迴虫,很难猜度得出阁下的想法的说。 |
10.Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! [Re: Alerander] | Copy to clipboard |
Posted by: Alerander Posted on: 2004-09-06 11:31 import java.io.*; 又试着写了一个这样的程序,还是没用啊~~~~急噪咯! |
11.Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! [Re: Alerander] | Copy to clipboard |
Posted by: Alerander Posted on: 2004-09-06 11:34 import java.io.*; class TestOneDeposit{ public static void main(String[] args)throws IOException{ boolean b=false; OneDeposit od=new OneDeposit("19860923","liye","fafadf","fafasf","fafafda", "fafdfa","wew","wee",b); OneDeposit odd=new OneDeposit("19660923","yydhe","fafadf","fafasf","fafafda", "fafdfa","wew","wee",b); od.createFiles(); RandomAccessFile out=new RandomAccessFile("存款文件.dat","rw"); od.write(out); odd.write(out); } } 》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》 import java.io.*; class TestOneDeposit2{ public static void main(String[] args)throws IOException{ boolean b=false; OneDeposit od=new OneDeposit(); RandomAccessFile in=new RandomAccessFile("存款文件.dat","rw"); od.read(in,"19860923"); System.out.println(od.number+od.name+od.password+od.capital+od.sort+od.saveDay+od.address+od.saveAssistant+od.isLost); } } 》》》》》》》》》》》》》》》 这就是刚刚的测试程序,很简单的 |
12.Re:谁能帮我看看这个类,为什么read()方法没有用啊?!! [Re: Alerander] | Copy to clipboard |
Posted by: Alerander Posted on: 2004-09-06 11:41 这位大哥,就是修改了能让它读出想要的帐户信息啊! |
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 |