public void tagSwapAndCopyFile() throws Exception {
  BufferedReader br=null;
  BufferedWriter bw=null;
  try {
    FileInputStream fi=new FileInputStream(getSourceFile());
    InputStreamReader ir=new InputStreamReader(fi,DEFAULT_ENCODING);
    br=new BufferedReader(ir);
    FileOutputStream fo=new FileOutputStream(getDestinationFile());
    OutputStreamWriter ow=new OutputStreamWriter(fo,DEFAULT_ENCODING);
    bw=new BufferedWriter(ow);
    StringBuffer tokenQueue=new StringBuffer(256);
    StringBuffer resultData=new StringBuffer();
    String lineData=null;
    while ((lineData=br.readLine()) != null) {
      String transformedLine=scanAndReplaceTokens(lineData,resultData,tokenQueue);
      bw.write(transformedLine);
    }
  }
 catch (  Exception e) {
    throw e;
  }
 finally {
    if (br != null) {
      try {
        br.close();
      }
 catch (      IOException ie) {
        Debug.log("ReplaceTokens.tagSwapAndCopy() - Exception " + "occurred while closing Reader. ",ie);
      }
    }
    if (bw != null) {
      try {
        bw.flush();
        bw.close();
      }
 catch (      IOException ie) {
        Debug.log("ReplaceTokens.tagSwapAndCopy() - Exception " + "occurred while closing Writer. ",ie);
      }
    }
  }
}

public void tagSwapAndCopyFile ( ) throws Exception { BufferedReader br = null ; BufferedWriter bw = null ; try { FileInputStream fi = new FileInputStream ( getSourceFile ( ) ) ; InputStreamReader ir = new InputStreamReader ( fi , DEFAULT_ENCODING ) ; br = new BufferedReader ( ir ) ; FileOutputStream fo = new FileOutputStream ( getDestinationFile ( ) ) ; OutputStreamWriter ow = new OutputStreamWriter ( fo , DEFAULT_ENCODING ) ; bw = new BufferedWriter ( ow ) ; StringBuffer tokenQueue = new StringBuffer ( 256 ) ; StringBuffer resultData = new StringBuffer ( ) ; String lineData = null ; while ( ( lineData = br . readLine ( ) ) != null ) { String transformedLine = scanAndReplaceTokens ( lineData , resultData , tokenQueue ) ; bw . write ( transformedLine ) ; } } catch ( Exception e ) { throw e ; } finally { if ( br != null ) { try { br . close ( ) ; } catch ( IOException ie ) { Debug . log ( "ReplaceTokens.tagSwapAndCopy() - Exception " + "occurred while closing Reader. " , ie ) ; } } if ( bw != null ) { try { bw . flush ( ) ; bw . close ( ) ; } catch ( IOException ie ) { Debug . log ( "ReplaceTokens.tagSwapAndCopy() - Exception " + "occurred while closing Writer. " , ie ) ; } } } }
method to perform the token - tag swap and create a destination file with the transformation .
