Android String to File Write appendTextToFile(String file, String text)

Here you can find the source of appendTextToFile(String file, String text)

Description

Simple method to append text to a file

License

Open Source License

Parameter

Parameter Description
file The filename (with full path) to write to
text Text to appendto the file

Declaration

public static final void appendTextToFile(String file, String text) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedWriter;

import java.io.FileWriter;

import java.io.IOException;
import java.io.PrintWriter;

public class Main {
    /**/* w ww .  j  a  v  a2 s. c o  m*/
     * Simple method to append text to a file
     * @param file The filename (with full path) to write to
     * @param text Text to appendto the file
     */
    public static final void appendTextToFile(String file, String text) {
        try {
            PrintWriter out = new PrintWriter(new BufferedWriter(
                    new FileWriter(file, true)));
            out.print(text);
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Related

  1. writeFile(List input, String inputFileName)