五个客户的材料存储在名为“Customer.txt”的文件中。第六个客户的材料必须添加到现有文件的内容。识别以下解决方案中哪个最能满足所述要求,。
/* entry为包含要写到文件的数据的串 */
1. RandomAccesFile logFile=new RandomAccessFile(“Customer.txt”, “rw”);
logFile.writeBytes(entry);2. RandomAccesFile logFile=new RandomAccessFile(“Customer.txt”, “rw”);
logFile.seek(logFile.length());
logFile.writeBytes(entry);3. FileOutputStream fswriter=new FileOutputStream(“Customer.txt”, true);
fswriter.write(entry.getBytes());4. FileOutputStream fswriter=new FileOutputStream(“Customer.txt”, false);
fswriter.write(entry.getBytes());
/* entry为包含要写到文件的数据的串 */
1. RandomAccesFile logFile=new RandomAccessFile(“Customer.txt”, “rw”);
logFile.writeBytes(entry);2. RandomAccesFile logFile=new RandomAccessFile(“Customer.txt”, “rw”);
logFile.seek(logFile.length());
logFile.writeBytes(entry);3. FileOutputStream fswriter=new FileOutputStream(“Customer.txt”, true);
fswriter.write(entry.getBytes());4. FileOutputStream fswriter=new FileOutputStream(“Customer.txt”, false);
fswriter.write(entry.getBytes());
解决方案 »
- java继承中,为什么成员变量可以隐藏,而方法不可以了?反过来,为什么方法可以覆盖而成员变量不可以了?
- 如何让JTable 的列头跨行列显示
- Java access modifer笔试题,你能答对吗?
- 字符串转编码后单个汉字出现乱码, 其他汉字显示正常
- Action和ActionListener的问题
- 出500块找位兄弟帮忙作个网络安全方面的程序(大致要求请进)
- 线程怎么不能停止??
- 虚心请教简单问题:java.lang.NullPointerException是如何产生的?应该如何解决?谢谢!
- 大家帮帮忙,有谁知道讲JAVA做拍卖例子的书?谢了!!!
- 紧急求救!!! JCreator Pro 2.0的注册码
- java 写 oracle 的 long 字段时,中文问题怎么样解决啊?
- 欢迎加入我的java群:25250314
fswriter.write(entry.getBytes());
1,4会覆盖掉原有的5个数据
2的理由没有想出来
只是感觉没3好用若有错误
还望楼下指正
public final void writeBytes(String s)
throws IOException;
这个的参数是个字符串;题目中的entry应该是个字节数组;