title: How to add files inside temporary directory in JUnit
body: <p>I found two ways to create temporary directories in JUnit.</p>
  
  <p>Way 1:</p>
  
  <pre><code>@Rule
  public TemporaryFolder tempDirectory = new TemporaryFolder();
  
  @Test
  public void testTempDirectory() throws Exception {
      tempDirectory.newFile("test.txt");
      tempDirectory.newFolder("myDirectory");
      // how do I add files to myDirectory?
  }
  </code></pre>
  
  <p>Way 2:</p>
  
  <pre><code>@Test
  public void testTempDirectory() throws Exception {
      File myFile = File.createTempFile("abc", "txt");
      File myDirectory = Files.createTempDir();
      // how do I add files to myDirectory?
  }
  </code></pre>
  
  <p>As the comment above mentions, I have a requirement where I want to add some temporary files in these temporary directories. Run my test against this structure and finally delete everything on exit. </p>
  
  <p>How do I do that?</p>