Android Text File Write writeFileEnd(String filepath, String text)

Here you can find the source of writeFileEnd(String filepath, String text)

Description

write File End

Declaration

public static void writeFileEnd(String filepath, String text) 

Method Source Code

//package com.java2s;

import java.io.File;

import java.io.FileOutputStream;
import java.io.IOException;

import java.io.OutputStreamWriter;

public class Main {
    public static void writeFileEnd(String filepath, String text) {
        OutputStreamWriter wr = null;
        try {/* ww w .  ja v a 2  s . c om*/
            File file = new File(filepath);
            if (!file.exists()) {
                file.getParentFile().mkdirs();
            }
            wr = new OutputStreamWriter(
                    new FileOutputStream(filepath, true), "UTF8");
            wr.write(text);
            wr.flush();

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (wr != null) {
                try {
                    wr.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

Related

  1. saveFile(String content, File file)
  2. writeFileSdcard(File file, String message)
  3. writeFile(String filepath, String text)
  4. writeStringToFile(String text, String filePath)
  5. writeToSDFile(String directory, String file_name, String text)
  6. WriteFile(String file, String message)
  7. writeNewFile(String filePath, String fileContents)
  8. writeStringToFile(File file, String data)
  9. writeTextFile(File file, String str)