title: FileNotFoundException when using FileOutputStream
body: <p>I need to extract tar file by this code.
  But it' this error when I use FileOutputStream(outputFile);</p>
  
  <pre><code>     " java.io.FileNotFoundException: D:\TestFile\1.png (Access is denied)"
  </code></pre>
  
  <p>Input is 1.tar file from Drive D:/testFile
  and extract to same folder</p>
  
  <p>I try check path of outputfile by outputFile.getCanonicalFile but it's ok!!
  what wrong?</p>
  
  <pre><code>   public class DecompressTarFile {
  
  public ArrayList&lt;File&gt; getTarFileExtracted() {
      return tarFileExtracted;
  }
  
  public ArrayList&lt;File&gt; tarFileExtracted = new ArrayList&lt;File&gt;();
  
  public DecompressTarFile(File inputFile, File outputDir) throws FileNotFoundException, ArchiveException, IOException {
  
      System.out.println("Untaring " + inputFile.getAbsolutePath() + " to dir " + outputDir.getAbsolutePath() + ".");
      InputStream inputStream = new FileInputStream(inputFile);
      TarArchiveInputStream tarStream = (TarArchiveInputStream) new ArchiveStreamFactory().createArchiveInputStream("tar", inputStream);
      TarArchiveEntry tarEntry = null;
      while ((tarEntry = (TarArchiveEntry) tarStream.getNextEntry()) != null) {
          File outputFile = new File(outputDir, tarEntry.getName());
          System.out.println("Attempting to write output directory " + outputFile.getAbsolutePath());
          if (!outputFile.exists()) {
              System.out.println("Attempting to create output directory " + outputFile.getAbsolutePath());
              if (!outputFile.mkdirs()) {
                  throw new IllegalStateException(String.format("Couldn't create directory %s.", outputFile.getAbsolutePath()));
              }
  
          } else {
              System.out.println("Create output file " + outputFile.getAbsolutePath());     
  
              OutputStream outputFileStream = new FileOutputStream(outputFile);
              IOUtils.copy(tarStream, outputFileStream);
              outputFileStream.close();
  
          }
          tarFileExtracted.add(outputFile);
      }
      tarStream.close();
  
  }
  
  }
  </code></pre>
  
  <p>and called by main class</p>
  
  <pre><code> static File tarFileInput = new File("D:/TestFile/haha.tar");
  static File tarPathFileOutput = new File("D:/TestFile");
  
   public static void main(String[] args) throws ArchiveException, IOException {
  
      decomp = new DecompressTarFile(tarFileInput, tarPathFileOutput);
      //listOutput = decomp.getTarFileExtracted();
  
  }
  </code></pre>
  
  <p>And this result from this code</p>
  
  <pre><code>   run:
      Untaring D:\TestFile\haha.tar to dir D:\TestFile.
      Attempting to write output directory D:\TestFile\1.png
      Create output file D:\TestFile\1.png
      Exception in thread "main" java.io.FileNotFoundException: D:\TestFile\1.png (Access  is denied)
       at java.io.FileOutputStream.open(Native Method)
       at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:221)
       at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:171)
       at com.service..TarFile.DecompressTarFile.&lt;init&gt;(DecompressTarFile.java:53)
        at com.service..TarFile.MainForTest.main(MainForTest.java:28)
  </code></pre>
  
  <p>Java Result: 1</p>