title: Unable to copy files using FileUtils
body: <p>I am trying to copy the files from one destination to another. I am unable to understand why the error occurs. Any help is appreciated.</p>
  
  <pre><code>public class FileSearch {
  
      public void findFiles(File root) throws IOException {
  
          File[] listOfFiles = root.listFiles();
          for (int i = 0; i &lt; listOfFiles.length; i++) {
              String iName = listOfFiles[i].getName();
              if (listOfFiles[i].isFile() &amp;&amp; iName.endsWith(".tif")) {
                  long fileSize = listOfFiles[i].length();
  
                  long sizeToKb = fileSize/1024;
  
                  File copyDest = new File("C:\\Users\\username\\Desktop\\ZipFiles");
  
                  if (fileSize &lt;= 600000) {
                      System.out.println("|" + listOfFiles[i].getName().toString() + " | Size: " + sizeToKb+" KB");
                      FileUtils.copyFile(listOfFiles[i], copyDest);
                  }
  
              } else if (listOfFiles[i].isDirectory()) {
                  findFiles(listOfFiles[i]);
              }
          }
      }
  </code></pre>
  
  <p>I get the following error <code>Exception in thread "main" java.io.IOException: Destination 'C:\Users\username\Desktop\ZipFiles' exists but is a directory</code></p>