title: Copying files from one directory to another in Java
body: <p>I want to copy files from one directory to another (subdirectory) using Java. I have a directory, dir, with text files. I iterate over the first 20 files in dir, and want to copy them to another directory in the dir directory, which I have created right before the iteration.
  In the code, I want to copy the <code>review</code> (which represents the ith text file or review) to <code>trainingDir</code>. How can I do this? There seems not to be such a function (or I couldn't find). Thank you.</p>
  
  <pre><code>boolean success = false;
  File[] reviews = dir.listFiles();
  String trainingDir = dir.getAbsolutePath() + "/trainingData";
  File trDir = new File(trainingDir);
  success = trDir.mkdir();
  for(int i = 1; i &lt;= 20; i++) {
      File review = reviews[i];
  
  }
  </code></pre>