用RandomAccessFile类进行文件读写进行文件内容输出时有问题
我的程序:import java.io.*;
public class MyRandomFileDemo1 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stube
try{
RandomAccessFile raf=new RandomAccessFile("MyRandomFileDemo1.java","rw");
int b;
byte[] buffer=new byte[100];
String str;
long fpoints=0;
do{
System.out.println("请输入要存盘的信息:");
b=System.in.read(buffer);
str=new String(buffer,0,b);
raf.write(buffer, 0, b);
}while(!str.equalsIgnoreCase("exit"+"\r\n"));
System.out.println("输出文件中的信息");
long length=raf.length();
while(fpoints<length){
String str1=raf.readLine();
System.out.println(str1);
fpoints=raf.getFilePointer();
}
raf.close();
}
catch(Exception e1){
e1.printStackTrace(System.out);
}
}
}
补充:Java , Java相关