Android Text File Append appendToFile(String sb, String directory, String fileName)

Here you can find the source of appendToFile(String sb, String directory, String fileName)

Description

append To File

License

Apache License

Declaration

public static void appendToFile(String sb, String directory,
            String fileName) 

Method Source Code

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

import java.io.*;

public class Main {
    public static void appendToFile(String sb, String directory,
            String fileName) {/*  w ww .j  a v a  2s . com*/
        if (!directory.endsWith("/")) {
            directory = directory + "/";
        }
        File out = new File(directory + fileName);
        try {
            Writer fw = new OutputStreamWriter(new FileOutputStream(out,
                    true), "UTF-8");
            try {
                fw.write(sb.toString());
                fw.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

    }
}

Related

  1. appendFile(File file, String content)
  2. appendLineToFile(String textToWrite, String fileName)
  3. appendString(String filename, String content)