Program: 64264
Project: 64264
Buggy source:
/** 
 * Convienence method to copy a file from a source to a destination specifying if token filtering must be used, if filter chains must be used, if source files may overwrite newer destination files and the last modified time of <code>destFile</code> file should be made equal to the last modified time of <code>sourceFile</code>.
 * @throws IOException
 * @since 1.15, Ant 1.5
 */
public void copyFile(File sourceFile,File destFile,FilterSetCollection filters,Vector filterChains,boolean overwrite,boolean preserveLastModified,String encoding,Project project) throws IOException {
  if (overwrite || !destFile.exists() || destFile.lastModified() < sourceFile.lastModified()) {
    if (destFile.exists() && destFile.isFile()) {
      destFile.delete();
    }
    File parent=getParentFile(destFile);
    if (!parent.exists()) {
      parent.mkdirs();
    }
    final boolean filterSetsAvailable=(filters != null && filters.hasFilters());
    final boolean filterChainsAvailable=(filterChains != null && filterChains.size() > 0);
    if (filterSetsAvailable || filterChainsAvailable) {
      BufferedReader in=null;
      BufferedWriter out=null;
      try {
        if (encoding == null) {
          in=new BufferedReader(new FileReader(sourceFile));
          out=new BufferedWriter(new FileWriter(destFile));
        }
 else {
          in=new BufferedReader(new InputStreamReader(new FileInputStream(sourceFile),encoding));
          out=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(destFile),encoding));
        }
        if (filterChainsAvailable) {
          ChainReaderHelper crh=new ChainReaderHelper();
          crh.setBufferSize(8192);
          crh.setPrimaryReader(in);
          crh.setFilterChains(filterChains);
          crh.setProject(project);
          Reader rdr=crh.getAssembledReader();
          in=new BufferedReader(rdr);
        }
        int length;
        String newline=null;
        String line=in.readLine();
        while (line != null) {
          if (line.length() == 0) {
            out.newLine();
          }
 else {
            if (filterSetsAvailable) {
              newline=filters.replaceTokens(line);
            }
 else {
              newline=line;
            }
            out.write(newline);
            out.newLine();
          }
          line=in.readLine();
        }
      }
  finally {
        if (out != null) {
          out.close();
        }
        if (in != null) {
          in.close();
        }
      }
    }
 else {
      FileInputStream in=null;
      FileOutputStream out=null;
      try {
        in=new FileInputStream(sourceFile);
        out=new FileOutputStream(destFile);
        byte[] buffer=new byte[8 * 1024];
        int count=0;
        do {
          out.write(buffer,0,count);
          count=in.read(buffer,0,buffer.length);
        }
 while (count != -1);
      }
  finally {
        if (out != null) {
          out.close();
        }
        if (in != null) {
          in.close();
        }
      }
    }
    if (preserveLastModified) {
      setFileLastModified(destFile,sourceFile.lastModified());
    }
  }
}

Fixed version (ground truth):
/** 
 * Convienence method to copy a file from a source to a destination specifying if token filtering must be used, if filter chains must be used, if source files may overwrite newer destination files and the last modified time of <code>destFile</code> file should be made equal to the last modified time of <code>sourceFile</code>.
 * @throws IOException
 * @since 1.15, Ant 1.5
 */
public void copyFile(File sourceFile,File destFile,FilterSetCollection filters,Vector filterChains,boolean overwrite,boolean preserveLastModified,String encoding,Project project) throws IOException {
  if (overwrite || !destFile.exists() || destFile.lastModified() < sourceFile.lastModified()) {
    if (destFile.exists() && destFile.isFile()) {
      destFile.delete();
    }
    File parent=getParentFile(destFile);
    if (!parent.exists()) {
      parent.mkdirs();
    }
    final boolean filterSetsAvailable=(filters != null && filters.hasFilters());
    final boolean filterChainsAvailable=(filterChains != null && filterChains.size() > 0);
    if (filterSetsAvailable || filterChainsAvailable) {
      BufferedReader in=null;
      BufferedWriter out=null;
      try {
        if (encoding == null) {
          in=new BufferedReader(new FileReader(sourceFile));
          out=new BufferedWriter(new FileWriter(destFile));
        }
 else {
          in=new BufferedReader(new InputStreamReader(new FileInputStream(sourceFile),encoding));
          out=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(destFile),encoding));
        }
        if (filterChainsAvailable) {
          ChainReaderHelper crh=new ChainReaderHelper();
          crh.setBufferSize(8192);
          crh.setPrimaryReader(in);
          crh.setFilterChains(filterChains);
          crh.setProject(project);
          Reader rdr=crh.getAssembledReader();
          in=new BufferedReader(rdr);
        }
        String newline=null;
        String line=in.readLine();
        while (line != null) {
          if (line.length() == 0) {
            out.newLine();
          }
 else {
            if (filterSetsAvailable) {
              newline=filters.replaceTokens(line);
            }
 else {
              newline=line;
            }
            out.write(newline);
            out.newLine();
          }
          line=in.readLine();
        }
      }
  finally {
        if (out != null) {
          out.close();
        }
        if (in != null) {
          in.close();
        }
      }
    }
 else {
      FileInputStream in=null;
      FileOutputStream out=null;
      try {
        in=new FileInputStream(sourceFile);
        out=new FileOutputStream(destFile);
        byte[] buffer=new byte[8 * 1024];
        int count=0;
        do {
          out.write(buffer,0,count);
          count=in.read(buffer,0,buffer.length);
        }
 while (count != -1);
      }
  finally {
        if (out != null) {
          out.close();
        }
        if (in != null) {
          in.close();
        }
      }
    }
    if (preserveLastModified) {
      setFileLastModified(destFile,sourceFile.lastModified());
    }
  }
}