Java: append string to a text file









public static void append(File f, String text) throws Throwable {
  BufferedWriter w; 
  try {
    w = new BufferedWriter(new FileWriter(f, true));
    w.write(text);
    w.flush();
  } finally {
    if(w!=null) {
      w.close();
    }
  }
}



No comments:

Post a Comment