private void mergeConfigFiles(String instanceConfigFileMigrate,String instanceConfigFile) throws Exception {
  BufferedReader br=null;
  PrintWriter pw=null;
  Debug.log("MigrateConfigurePropertiesTask.mergeConfigFiles() - " + "config file to migrate from: " + instanceConfigFileMigrate + " config file to migrate to: "+ instanceConfigFile);
  try {
    FileReader fr=new FileReader(instanceConfigFile);
    br=new BufferedReader(fr);
    String tmpFileName=instanceConfigFile + ".tmp";
    pw=new PrintWriter(new FileWriter(tmpFileName));
    String lineData=null;
    KeyValue keyValue=null;
    ArrayList migrateLines=null;
    while ((lineData=br.readLine()) != null) {
      lineData=lineData.trim();
      if (lineData.startsWith(FileUtils.HASH) || lineData.length() == 0) {
        pw.println(lineData);
      }
 else {
        keyValue=new KeyValue(lineData);
        if (nonMigratedParameters.contains(keyValue.getKey())) {
          pw.println(lineData);
          continue;
        }
        migrateLines=getMigrateLines(keyValue.getParameter(),instanceConfigFileMigrate);
        Debug.log("MigrateConfigurePropertiesTask.mergeConfigFiles() - " + "parameter: " + keyValue.getParameter() + " matched migration parameter: "+ migrateLines);
        if (migrateLines.size() > 0) {
          for (int i=0; i < migrateLines.size(); i++) {
            pw.println(migrateLines.get(i));
          }
        }
 else {
          pw.println(lineData);
        }
      }
    }
    br.close();
    pw.flush();
    pw.close();
    FileUtils.copyFile(tmpFileName,instanceConfigFile);
    File tmpFile=new File(tmpFileName);
    tmpFile.delete();
  }
 catch (  Exception ex) {
    if (br != null) {
      try {
        br.close();
      }
 catch (      Exception ex1) {
      }
    }
    if (pw != null) {
      try {
        pw.close();
      }
 catch (      Exception ex1) {
      }
    }
  }
}

private void mergeConfigFiles ( String instanceConfigFileMigrate , String instanceConfigFile ) throws Exception { BufferedReader br = null ; PrintWriter pw = null ; Debug . log ( "MigrateConfigurePropertiesTask.mergeConfigFiles() - " + "config file to migrate from: " + instanceConfigFileMigrate + " config file to migrate to: " + instanceConfigFile ) ; try { FileReader fr = new FileReader ( instanceConfigFile ) ; br = new BufferedReader ( fr ) ; String tmpFileName = instanceConfigFile + ".tmp" ; pw = new PrintWriter ( new FileWriter ( tmpFileName ) ) ; String lineData = null ; KeyValue keyValue = null ; ArrayList migrateLines = null ; while ( ( lineData = br . readLine ( ) ) != null ) { lineData = lineData . trim ( ) ; if ( lineData . startsWith ( FileUtils . HASH ) || lineData . length ( ) == 0 ) { pw . println ( lineData ) ; } else { keyValue = new KeyValue ( lineData ) ; if ( nonMigratedParameters . contains ( keyValue . getKey ( ) ) ) { pw . println ( lineData ) ; continue ; } migrateLines = getMigrateLines ( keyValue . getParameter ( ) , instanceConfigFileMigrate ) ; Debug . log ( "MigrateConfigurePropertiesTask.mergeConfigFiles() - " + "parameter: " + keyValue . getParameter ( ) + " matched migration parameter: " + migrateLines ) ; if ( migrateLines . size ( ) > 0 ) { for ( int i = 0 ; i < migrateLines . size ( ) ; i ++ ) { pw . println ( migrateLines . get ( i ) ) ; } } else { pw . println ( lineData ) ; } } } br . close ( ) ; pw . flush ( ) ; pw . close ( ) ; FileUtils . copyFile ( tmpFileName , instanceConfigFile ) ; File tmpFile = new File ( tmpFileName ) ; tmpFile . delete ( ) ; } catch ( Exception ex ) { if ( br != null ) { try { br . close ( ) ; } catch ( Exception ex1 ) { } } if ( pw != null ) { try { pw . close ( ) ; } catch ( Exception ex1 ) { } } } }
merge previous product ' s config file with the one newly generated .
