save Text File with FileWriter - Android java.io

Android examples for java.io:FileWriter

Description

save Text File with FileWriter

Demo Code

import java.io.File;
import java.io.FileWriter;

public class Main {

  public static boolean saveTextFile(File file, String text) {
    try {// ww  w  .j a  v a  2 s.  co  m
      FileWriter writer = new FileWriter(file);
      writer.append(text);
      writer.flush();
      writer.close();
      return true;
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
  }

}

Related Tutorials