public class RandomAccessFileDemo {
public static void main(String[] args) throws IOException{
System.out.println("输入内容:");
Scanner console=new Scanner(System.in);
String str=console.nextLine();
RandomAccessFile raf=new RandomAccessFile("test.txt","rw");
while((str=console.nextLine())!=null){
raf.write(str.getBytes("gbk"));
if(str.equals("exit")){
break;
}
}
raf.close();
}
}
public class RandomAccessFileDemo {
public static void main(String[] args) throws IOException{
System.out.println("输入内容:");
Scanner console=new Scanner(System.in);
String str=console.nextLine();
RandomAccessFile raf=new RandomAccessFile("test.txt","rw");
int count=0;
while((str=console.nextLine())!=null){
if(count==0){
countinue;
}
count++;
raf.write(str.getBytes("gbk"));
if(str.equals("exit")){
break;
}
}
raf.close();
}
}