提示

Java IO PrintWriter 使用示例。@ermo

回到上一级

    public static void write() throws IOException {
        String filepath = "src/main/resources/reader/output.txt";
        FileWriter fileWriter = new FileWriter(filepath);

        String str = "Some text wait to write from PrintWriter.";
        PrintWriter writer = new PrintWriter(fileWriter, true);
        writer.write(str);
        writer.flush();
        writer.close();
    }

    public static void main(String[] args) throws IOException {
        write();
    }