Android Text File Write writeFile(String file, T data, boolean append)

Here you can find the source of writeFile(String file, T data, boolean append)

Description

write File

Declaration

public static <T> void writeFile(String file, T data, boolean append) 

Method Source Code

//package com.java2s;

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

public class Main {

    public static <T> void writeFile(String file, T data, boolean append) {
        FileWriter writer = null;

        try {/*from  w  w  w .ja v  a 2 s  .  co m*/
            writer = new FileWriter(file, append);

            writer.write(data.toString());
            writer.flush();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                writer.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

Related

  1. writeFile(File file, String content)
  2. writeFile(File file, String content, String encoding)
  3. writeFile(File file, String text)
  4. writeFile(File out, String text)
  5. writeFile(OutputStream output, String text)
  6. writeFile(String fileName, String content)
  7. writeFile(String fileName, String text)
  8. writeFile(String fileName, String text, boolean isAppend)
  9. writeFile(String filePath, String content)