Java Text File Write writeString(File file, String content, boolean append)

Here you can find the source of writeString(File file, String content, boolean append)

Description

write String

License

Apache License

Declaration

public static void writeString(File file, String content, boolean append) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.File;

import java.io.FileWriter;
import java.io.IOException;

public class Main {
    public static void writeString(File file, String content, boolean append) {
        try {/*  w  w  w . jav  a  2s .c  o m*/
            if (!file.exists()) {
                file.getParentFile().mkdirs();
                file.createNewFile();
            }
            final FileWriter fileWriter = new FileWriter(file, append);
            fileWriter.append(content);
            fileWriter.close();
        } catch (final IOException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. writeString(File file, String data)
  2. writeString(File file, String s, int bufferSize, String encoding)
  3. writeString(File file, String str)
  4. writeString(File file, String str, String encoding)