public static boolean appendLinesToFile(String filePath,String[] linesToAppend,boolean create){
  boolean result=false;
  try {
    if (linesToAppend != null && linesToAppend.length > 0) {
      LineNumberReader reader=getLineNumReader(filePath,create);
      StringWriter writer=new StringWriter();
      String line=null;
      while ((line=reader.readLine()) != null) {
        writeLine(writer,line);
      }
      for (int i=0; i < linesToAppend.length; i++) {
        writeLine(writer,linesToAppend[i]);
      }
      String tempFilePath=filePath + ".tmp";
      result=writeToFile(tempFilePath,writer);
      if (result) {
        File tempFile=new File(tempFilePath);
        if (tempFile.exists() && tempFile.isFile()) {
          result=copyFile(tempFilePath,filePath);
          if (result) {
            result=tempFile.delete();
          }
        }
      }
    }
  }
 catch (  Exception ex) {
    result=false;
    Debug.log("FileUtils.appendLinesToFile() threw exception : ",ex);
  }
  return result;
}

public static boolean appendLinesToFile ( String filePath , String [ ] linesToAppend , boolean create ) { boolean result = false ; try { if ( linesToAppend != null && linesToAppend . length > 0 ) { LineNumberReader reader = getLineNumReader ( filePath , create ) ; StringWriter writer = new StringWriter ( ) ; String line = null ; while ( ( line = reader . readLine ( ) ) != null ) { writeLine ( writer , line ) ; } for ( int i = 0 ; i < linesToAppend . length ; i ++ ) { writeLine ( writer , linesToAppend [ i ] ) ; } String tempFilePath = filePath + ".tmp" ; result = writeToFile ( tempFilePath , writer ) ; if ( result ) { File tempFile = new File ( tempFilePath ) ; if ( tempFile . exists ( ) && tempFile . isFile ( ) ) { result = copyFile ( tempFilePath , filePath ) ; if ( result ) { result = tempFile . delete ( ) ; } } } } } catch ( Exception ex ) { result = false ; Debug . log ( "FileUtils.appendLinesToFile() threw exception : " , ex ) ; } return result ; }
appends the given set of lines to the specified file .
