import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class TestFile {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
Scanner san = new Scanner(System.in);
System.out.print("请输入:");
String str = san.nextLine();
FileWriter fw = null;
File f = new File("c:/file.txt");
fw = new FileWriter(f, true);
PrintWriter pw = new PrintWriter(fw);
pw.print(str);
pw.flush();
fw.flush();
pw.close();
fw.close();
System.out.println("成功!");
}
}
温馨提示:答案为网友推荐,仅供参考