public static boolean writeToFile(String filename,String message,boolean append){
  boolean result;
  BufferedWriter writer;
  try {
    writer=new BufferedWriter(new FileWriter(filename,append));
    writer.write(message);
    writer.newLine();
    writer.flush();
    writer.close();
    result=true;
  }
 catch (  Exception e) {
    result=false;
  }
  return result;
}

public static boolean writeToFile ( String filename , String message , boolean append ) { boolean result ; BufferedWriter writer ; try { writer = new BufferedWriter ( new FileWriter ( filename , append ) ) ; writer . write ( message ) ; writer . newLine ( ) ; writer . flush ( ) ; writer . close ( ) ; result = true ; } catch ( Exception e ) { result = false ; } return result ; }
writes the given message to the specified file . the message is either appended or replaces the current content of the file .
