title: How to copy file from one location to another location?
body: <p>I want to copy a file from one location to another location in Java. What is the best way to do this?</p>
  
  <hr>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>import java.io.File;
  import java.io.FilenameFilter;
  import java.util.ArrayList;
  import java.util.List;
  public class TestArrayList {
      public static void main(String[] args) {
          File f = new File(
              "D:\\CBSE_Demo\\Demo_original\\fscommand\\contentplayer\\config");
          List&lt;String&gt;temp=new ArrayList&lt;String&gt;();
          temp.add(0, "N33");
          temp.add(1, "N1417");
          temp.add(2, "N331");
          File[] matchingFiles = null;
          for(final String temp1: temp){
              matchingFiles = f.listFiles(new FilenameFilter() {
                  public boolean accept(File dir, String name) {
                      return name.startsWith(temp1);
                  }
              });
              System.out.println("size&gt;&gt;--"+matchingFiles.length);
  
          }
      }
  }
  </code></pre>
  
  <p>This does not copy the file, what is the best way to do this?</p>