代码以及解释:
package java2;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
public class Test02 {
public static void main(String[] args) throws IOException {
String str = "flag{hello_ctf}";
//1.封装
File f=new File("D:\\....test\\资料\\demo.txt");
//2.输出流,(插入管子),并起一个名字
FileWriter fw =new FileWriter(f);
//3.输出
fw.write(str);
//4.流关闭
fw.close();
}
}