Java Text File Append appendStringToFile(File file, String string)

Here you can find the source of appendStringToFile(File file, String string)

Description

append String To File

License

Apache License

Declaration

public static File appendStringToFile(File file, String string) 

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 File appendStringToFile(File file, String string) {
        FileWriter fileWriter = null;
        try {//from  www . j  a  v  a  2  s. c  o m
            fileWriter = new FileWriter(file, true);
            fileWriter.append(string);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                fileWriter.flush();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                fileWriter.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return file;
    }
}

Related

  1. add2File(String fileName, String content)
  2. appendStringToFile(File f, String s)
  3. appendStringToFile(File file, String string)
  4. appendStringToFile(File file, String string)
  5. appendStringToFile(final String path, final String output)
  6. appendStringToFile(String file, String contents)
  7. appendStringToFile(String fileName, String data)
  8. appendStringToFile(String str, String oFileName)