package test.cn.estsh.i3plus.core.apiservice.serviceimpl.busi;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;

/**
 * @Description :
 * @Reference :
 * @Author : Adair Peng
 * @CreateDate : 2019-02-25 15:36
 * @Modify:
 **/
public class JavaTest {
    public static void main(String[] args) throws Exception {
        for (int i = 0; i < 10; i++) {
            System.out.println("Hello World !~ -> " + i);
            fileWriter("E:\\test\\test.txt", "Hello World !~ -> " + i);
        }
    }

//    public static void fileWriter(String fileName, String txt) throws Exception {
//        PrintStream fileStream = new PrintStream(new File(fileName));
//        fileStream.println(txt);
//    }


    public static void fileWriter(String fileName, String content) {
        try {
        // 打开一个写文件器，构造函数中的第二个参数true表示以追加形式写文件   
            FileWriter writer = new FileWriter(fileName, true);
            writer.write(content+"\r\n");
            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
