java——写入到文件txt

2019年2月23日00:41:19 发表评论 1,436 views
package filetest;
import java.io.*;
public class writefile {

    public static void main(String[] args) {
        // TODO 自动生成的方法存根
        PrintWriter out = null;
        File f = new File("c:\\temp3.txt");
        try{
            out = new PrintWriter(new FileWriter(f));
        }
        catch(IOException e){
            e.printStackTrace();
        }
        //由FileWriter实例化,则向文件中输出
        out.print("Hello World!"+"\r\n");
        out.close();

    }

}

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: