Program: 64152
Project: 64152
Buggy source:
/** 
 * Convenience method to copy content from one Resource to another specifying whether token filtering must be used, whether filter chains must be used, whether newer destination files may be overwritten and whether the last modified time of <code>dest</code> file should be made equal to the last modified time of <code>source</code>.
 * @param source the Resource to copy from.Must not be <code>null</code>.
 * @param dest   the Resource to copy to.Must not be <code>null</code>.
 * @param filters the collection of filters to apply to this copy.
 * @param filterChains filterChains to apply during the copy.
 * @param overwrite Whether or not the destination Resource should beoverwritten if it already exists.
 * @param preserveLastModified Whether or not the last modified time ofthe destination Resource should be set to that of the source.
 * @param append Whether to append to an Appendable Resource.
 * @param inputEncoding the encoding used to read the files.
 * @param outputEncoding the encoding used to write the files.
 * @param project the project instance.
 * @param force whether read-only taret files will be overwritten
 * @throws IOException if the copying fails.
 * @since Ant 1.8.2
 */
public static void copyResource(Resource source,Resource dest,FilterSetCollection filters,Vector filterChains,boolean overwrite,boolean preserveLastModified,boolean append,String inputEncoding,String outputEncoding,Project project,boolean force) throws IOException {
  if (!(overwrite || SelectorUtils.isOutOfDate(source,dest,FileUtils.getFileUtils().getFileTimestampGranularity()))) {
    return;
  }
  final boolean filterSetsAvailable=(filters != null && filters.hasFilters());
  final boolean filterChainsAvailable=(filterChains != null && filterChains.size() > 0);
  File destFile=null;
  if (dest.as(FileProvider.class) != null) {
    destFile=((FileProvider)dest.as(FileProvider.class)).getFile();
  }
  if (destFile != null && destFile.isFile() && !destFile.canWrite()) {
    if (!force) {
      throw new IOException("String_Node_Str" + "String_Node_Str" + destFile);
    }
 else     if (!FILE_UTILS.tryHardToDelete(destFile)) {
      throw new IOException("String_Node_Str" + "String_Node_Str" + destFile);
    }
  }
  if (filterSetsAvailable) {
    BufferedReader in=null;
    BufferedWriter out=null;
    try {
      InputStreamReader isr=null;
      if (inputEncoding == null) {
        isr=new InputStreamReader(source.getInputStream());
      }
 else {
        isr=new InputStreamReader(source.getInputStream(),inputEncoding);
      }
      in=new BufferedReader(isr);
      OutputStream os=getOutputStream(dest,append,project);
      OutputStreamWriter osw;
      if (outputEncoding == null) {
        osw=new OutputStreamWriter(os);
      }
 else {
        osw=new OutputStreamWriter(os,outputEncoding);
      }
      out=new BufferedWriter(osw);
      if (filterChainsAvailable) {
        ChainReaderHelper crh=new ChainReaderHelper();
        crh.setBufferSize(FileUtils.BUF_SIZE);
        crh.setPrimaryReader(in);
        crh.setFilterChains(filterChains);
        crh.setProject(project);
        Reader rdr=crh.getAssembledReader();
        in=new BufferedReader(rdr);
      }
      LineTokenizer lineTokenizer=new LineTokenizer();
      lineTokenizer.setIncludeDelims(true);
      String newline=null;
      String line=lineTokenizer.getToken(in);
      while (line != null) {
        if (line.length() == 0) {
          out.newLine();
        }
 else {
          newline=filters.replaceTokens(line);
          out.write(newline);
        }
        line=lineTokenizer.getToken(in);
      }
    }
  finally {
      FileUtils.close(out);
      FileUtils.close(in);
    }
  }
 else   if (filterChainsAvailable || (inputEncoding != null && !inputEncoding.equals(outputEncoding)) || (inputEncoding == null && outputEncoding != null)) {
    BufferedReader in=null;
    BufferedWriter out=null;
    try {
      InputStreamReader isr=null;
      if (inputEncoding == null) {
        isr=new InputStreamReader(source.getInputStream());
      }
 else {
        isr=new InputStreamReader(source.getInputStream(),inputEncoding);
      }
      in=new BufferedReader(isr);
      OutputStream os=getOutputStream(dest,append,project);
      OutputStreamWriter osw;
      if (outputEncoding == null) {
        osw=new OutputStreamWriter(os);
      }
 else {
        osw=new OutputStreamWriter(os,outputEncoding);
      }
      out=new BufferedWriter(osw);
      if (filterChainsAvailable) {
        ChainReaderHelper crh=new ChainReaderHelper();
        crh.setBufferSize(FileUtils.BUF_SIZE);
        crh.setPrimaryReader(in);
        crh.setFilterChains(filterChains);
        crh.setProject(project);
        Reader rdr=crh.getAssembledReader();
        in=new BufferedReader(rdr);
      }
      char[] buffer=new char[FileUtils.BUF_SIZE];
      while (true) {
        int nRead=in.read(buffer,0,buffer.length);
        if (nRead == -1) {
          break;
        }
        out.write(buffer,0,nRead);
      }
    }
  finally {
      FileUtils.close(out);
      FileUtils.close(in);
    }
  }
 else   if (source.as(FileProvider.class) != null && destFile != null) {
    File sourceFile=((FileProvider)source.as(FileProvider.class)).getFile();
    File parent=destFile.getParentFile();
    if (parent != null && !parent.isDirectory() && !destFile.getParentFile().mkdirs()) {
      throw new IOException("String_Node_Str" + "String_Node_Str" + destFile);
    }
    FileInputStream in=null;
    FileOutputStream out=null;
    FileChannel srcChannel=null;
    FileChannel destChannel=null;
    try {
      in=new FileInputStream(sourceFile);
      out=new FileOutputStream(destFile);
      srcChannel=in.getChannel();
      destChannel=out.getChannel();
      long position=0;
      long count=srcChannel.size();
      while (position < count) {
        long chunck=Math.min(MAX_IO_CHUNCK_SIZE,count - position);
        position+=srcChannel.transferTo(position,chunck,destChannel);
      }
    }
  finally {
      FileUtils.close(srcChannel);
      FileUtils.close(destChannel);
      FileUtils.close(out);
      FileUtils.close(in);
    }
  }
 else {
    InputStream in=null;
    OutputStream out=null;
    try {
      in=source.getInputStream();
      out=getOutputStream(dest,append,project);
      byte[] buffer=new byte[FileUtils.BUF_SIZE];
      int count=0;
      do {
        out.write(buffer,0,count);
        count=in.read(buffer,0,buffer.length);
      }
 while (count != -1);
    }
  finally {
      FileUtils.close(out);
      FileUtils.close(in);
    }
  }
  if (preserveLastModified) {
    Touchable t=(Touchable)dest.as(Touchable.class);
    if (t != null) {
      setLastModified(t,source.getLastModified());
    }
  }
}

Fixed version (ground truth):
/** 
 * Convenience method to copy content from one Resource to another specifying whether token filtering must be used, whether filter chains must be used, whether newer destination files may be overwritten and whether the last modified time of <code>dest</code> file should be made equal to the last modified time of <code>source</code>.
 * @param source the Resource to copy from.Must not be <code>null</code>.
 * @param dest   the Resource to copy to.Must not be <code>null</code>.
 * @param filters the collection of filters to apply to this copy.
 * @param filterChains filterChains to apply during the copy.
 * @param overwrite Whether or not the destination Resource should beoverwritten if it already exists.
 * @param preserveLastModified Whether or not the last modified time ofthe destination Resource should be set to that of the source.
 * @param append Whether to append to an Appendable Resource.
 * @param inputEncoding the encoding used to read the files.
 * @param outputEncoding the encoding used to write the files.
 * @param project the project instance.
 * @param force whether read-only taret files will be overwritten
 * @throws IOException if the copying fails.
 * @since Ant 1.8.2
 */
public static void copyResource(Resource source,Resource dest,FilterSetCollection filters,Vector filterChains,boolean overwrite,boolean preserveLastModified,boolean append,String inputEncoding,String outputEncoding,Project project,boolean force) throws IOException {
  if (!(overwrite || SelectorUtils.isOutOfDate(source,dest,FileUtils.getFileUtils().getFileTimestampGranularity()))) {
    return;
  }
  final boolean filterSetsAvailable=(filters != null && filters.hasFilters());
  final boolean filterChainsAvailable=(filterChains != null && filterChains.size() > 0);
  File destFile=null;
  if (dest.as(FileProvider.class) != null) {
    destFile=((FileProvider)dest.as(FileProvider.class)).getFile();
  }
  if (destFile != null && destFile.isFile() && !destFile.canWrite()) {
    if (!force) {
      throw new IOException("String_Node_Str" + "String_Node_Str" + destFile);
    }
 else     if (!FILE_UTILS.tryHardToDelete(destFile)) {
      throw new IOException("String_Node_Str" + "String_Node_Str" + destFile);
    }
  }
  if (filterSetsAvailable) {
    BufferedReader in=null;
    BufferedWriter out=null;
    try {
      InputStreamReader isr=null;
      if (inputEncoding == null) {
        isr=new InputStreamReader(source.getInputStream());
      }
 else {
        isr=new InputStreamReader(source.getInputStream(),inputEncoding);
      }
      in=new BufferedReader(isr);
      OutputStream os=getOutputStream(dest,append,project);
      OutputStreamWriter osw;
      if (outputEncoding == null) {
        osw=new OutputStreamWriter(os);
      }
 else {
        osw=new OutputStreamWriter(os,outputEncoding);
      }
      out=new BufferedWriter(osw);
      if (filterChainsAvailable) {
        ChainReaderHelper crh=new ChainReaderHelper();
        crh.setBufferSize(FileUtils.BUF_SIZE);
        crh.setPrimaryReader(in);
        crh.setFilterChains(filterChains);
        crh.setProject(project);
        Reader rdr=crh.getAssembledReader();
        in=new BufferedReader(rdr);
      }
      LineTokenizer lineTokenizer=new LineTokenizer();
      lineTokenizer.setIncludeDelims(true);
      String newline=null;
      String line=lineTokenizer.getToken(in);
      while (line != null) {
        if (line.length() == 0) {
          out.newLine();
        }
 else {
          newline=filters.replaceTokens(line);
          out.write(newline);
        }
        line=lineTokenizer.getToken(in);
      }
    }
  finally {
      FileUtils.close(out);
      FileUtils.close(in);
    }
  }
 else   if (filterChainsAvailable || (inputEncoding != null && !inputEncoding.equals(outputEncoding)) || (inputEncoding == null && outputEncoding != null)) {
    BufferedReader in=null;
    BufferedWriter out=null;
    try {
      InputStreamReader isr=null;
      if (inputEncoding == null) {
        isr=new InputStreamReader(source.getInputStream());
      }
 else {
        isr=new InputStreamReader(source.getInputStream(),inputEncoding);
      }
      in=new BufferedReader(isr);
      OutputStream os=getOutputStream(dest,append,project);
      OutputStreamWriter osw;
      if (outputEncoding == null) {
        osw=new OutputStreamWriter(os);
      }
 else {
        osw=new OutputStreamWriter(os,outputEncoding);
      }
      out=new BufferedWriter(osw);
      if (filterChainsAvailable) {
        ChainReaderHelper crh=new ChainReaderHelper();
        crh.setBufferSize(FileUtils.BUF_SIZE);
        crh.setPrimaryReader(in);
        crh.setFilterChains(filterChains);
        crh.setProject(project);
        Reader rdr=crh.getAssembledReader();
        in=new BufferedReader(rdr);
      }
      char[] buffer=new char[FileUtils.BUF_SIZE];
      while (true) {
        int nRead=in.read(buffer,0,buffer.length);
        if (nRead == -1) {
          break;
        }
        out.write(buffer,0,nRead);
      }
    }
  finally {
      FileUtils.close(out);
      FileUtils.close(in);
    }
  }
 else   if (source.as(FileProvider.class) != null && destFile != null) {
    File sourceFile=((FileProvider)source.as(FileProvider.class)).getFile();
    File parent=destFile.getParentFile();
    if (parent != null && !parent.isDirectory() && !destFile.getParentFile().mkdirs()) {
      throw new IOException("String_Node_Str" + "String_Node_Str" + destFile);
    }
    FileInputStream in=null;
    FileOutputStream out=null;
    FileChannel srcChannel=null;
    FileChannel destChannel=null;
    try {
      in=new FileInputStream(sourceFile);
      out=new FileOutputStream(destFile);
      srcChannel=in.getChannel();
      destChannel=out.getChannel();
      long position=0;
      long count=srcChannel.size();
      while (position < count) {
        long chunk=Math.min(MAX_IO_CHUNCK_SIZE,count - position);
        position+=srcChannel.transferTo(position,chunk,destChannel);
      }
    }
  finally {
      FileUtils.close(srcChannel);
      FileUtils.close(destChannel);
      FileUtils.close(out);
      FileUtils.close(in);
    }
  }
 else {
    InputStream in=null;
    OutputStream out=null;
    try {
      in=source.getInputStream();
      out=getOutputStream(dest,append,project);
      byte[] buffer=new byte[FileUtils.BUF_SIZE];
      int count=0;
      do {
        out.write(buffer,0,count);
        count=in.read(buffer,0,buffer.length);
      }
 while (count != -1);
    }
  finally {
      FileUtils.close(out);
      FileUtils.close(in);
    }
  }
  if (preserveLastModified) {
    Touchable t=(Touchable)dest.as(Touchable.class);
    if (t != null) {
      setLastModified(t,source.getLastModified());
    }
  }
}