title: Writing to temp dir Caused by: java.io.FileNotFoundException
body: <p>Hi I have a java app that I'm trying to write to a tempDir with, but I continue to get the following exception. I'll admit I don't know much about writing files, so hopefully it's something minor I'm missing. </p>
  
  <pre><code>Caused by: java.io.FileNotFoundException
  </code></pre>
  
  <p>I have the following code. </p>
  
  <p><a href="https://code.google.com/p/sitemapgen4j/" rel="nofollow">https://code.google.com/p/sitemapgen4j/</a></p>
  
  <pre><code>File file = File.createTempFile(System.getProperty("java.io.tmpdir"), null);
  
          WebSitemapGenerator wsg = new WebSitemapGenerator("http://www.example.com", file);
          wsg.addUrl("http://www.example.com/index.html"); // repeat multiple times
          wsg.write();
  
          ByteArrayOutputStream out = new ByteArrayOutputStream();
          OutputStream outputStream = new FileOutputStream(file);
          out.writeTo(outputStream);
  </code></pre>
  
  <p>Stack trace</p>
  
  <pre><code>/var/folders/tp/jr6gqrhn7bs18szx5ck_b3qc0000gn/T/
  ioc.Registry Problem writing sitemap file /var/folders/tp/jr6gqrhn7bs18szx5ck_b3qc0000gn/T/T2742577239986554001.tmp/sitemap.xml
  ioc.Registry Operations trace:
  ioc.Registry [ 1] Handling traditional 'action' component event request for account/admin/Index:sitemap.
  ioc.Registry [ 2] Triggering event 'action' on account/admin/Index:sitemap
  TapestryModule.RequestExceptionHandler Processing of request failed with uncaught exception: org.apache.tapestry5.ioc.internal.OperationException: Problem writing sitemap file /var/folders/tp/jr6gqrhn7bs18szx5ck_b3qc0000gn/T/T2742577239986554001.tmp/sitemap.xml [at classpath:com/domain/auto/pages/account/admin/AdminIndex.tml, line 32]
  Caused by: java.io.FileNotFoundException: /var/folders/tp/jr6gqrhn7bs18szx5ck_b3qc0000gn/T/T2742577239986554001.tmp/sitemap.xml (Not a directory)
      at java.io.FileOutputStream.open(Native Method)
      at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:213)
      at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:162)
      at java.io.FileWriter.&lt;init&gt;(FileWriter.java:90)
      at com.redfin.sitemapgenerator.SitemapGenerator.writeSiteMap(SitemapGenerator.java:198)
      ... 105 more
  </code></pre>