62,616
社区成员
发帖
与我相关
我的任务
分享
public class InputTxt {
public static void main(String args[]) throws Exception{
/*
* 此类的作用是为了将数据写入的文本文件中结尾
*/
File file=new File("student.txt");
//根据给定的文件名以及指示是否附加写入数据的 boolean true表示写道文件的最后 值来构造 FileWriter 对象。
FileWriter fw=new FileWriter(file,true);
Scanner sc=new Scanner(System.in);
String ss=sc.next();//输入
ss=ss+"\r";
fw.write(ss.toCharArray());
fw.flush();
fw.close();
sc.close();
}
}