- 闲的无聊,写了个Java代码模拟一下记事本
public static void Demo_08() throws IOException{
Scanner sc = new Scanner(System.in);
System.out.print("请输入记事本名字:");
String s = sc.nextLine() + ".txt";
System.out.println("此为记事本,请输入:");
FileOutputStream fileOutputStream = new FileOutputStream(s);
while(true){
String s2 = sc.nextLine();
if(s2.equals("QUIT")) break;
fileOutputStream.write(s2.getBytes());
fileOutputStream.write("\r\n".getBytes());
}
}
便可以生成一个helloworld.txt
文件
成功模拟出了记事本功能
闲着无聊请勿模仿