package day07;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.io.UnsupportedEncodingException;
import java.util.Scanner;
public class Note {
public static void main(String[] args) throws IOException {
System.out.println("请输入文件名:");
Scanner scan = new Scanner(System.in);
String str = scan.nextLine();
RandomAccessFile sdf =new RandomAccessFile("str","rw");
System.out.println("请输入您要书写的内容:");
System.out.println("如果想退出请输入exit");
while(true){
String sub = scan.nextLine();
if("exit".equals(sub)){
break;
}else{
byte [] data = sub.getBytes("GBK");
sdf.write(data);
}
}
System.out.println("再见!");
sdf.close();
}
}
|