Java Write String to File writeFile(String filePath, String text)

Here you can find the source of writeFile(String filePath, String text)

Description

write File

License

Apache License

Declaration

public static void writeFile(String filePath, String text) 

Method Source Code

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

import java.io.BufferedWriter;

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

public class Main {
    public static void writeFile(String filePath, String text) {

        BufferedWriter bw = null;
        try {//from w  ww  .ja v  a2s .co m
            bw = new BufferedWriter(new FileWriter(filePath, true));
            bw.write(text);
            bw.flush();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            try {
                bw.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            bw = null;
        }
    }
}

Related

  1. writeFile(String filePath, String contents)
  2. writeFile(String filePath, String fileContent)
  3. writeFile(String filePath, String fileData, boolean isAppend)
  4. writeFile(String filePath, String fileName, String[] args)
  5. writeFile(String filePath, String templetContent, String charsetName)