title: Can I trust methods in Files will throw NoSuchFileException when expected?
body: <p>The <a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html"><code>java.nio.file.Files</code></a> API is a really nice improvement over the old <code>java.io.File</code> class, but one detail strikes me as odd; with the exception of <a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#delete-java.nio.file.Path-"><code>delete()</code></a> no methods document that they may throw <code>NoSuchFileException</code>, and even <code>delete()</code> says this is optional.</p>
  
  <p>I'd like to be able to differentiate between failures due to missing files and other IO issues, but it seems this isn't guaranteed to be possible.</p>
  
  <p>The alternative of calling <code>Files.exists()</code> and the like beforehand risks a race-condition if the file is created in between the two operations.</p>
  
  <p>Can I expect methods in <code>Files</code> will raise a <code>NoSuchFileException</code> when appropriate?  If so, where is this documented?  If not, how can I safely determine the failure is due to a missing file?</p>
  
  <hr>
  
  <p><strong>Example:</strong> On Windows 7 with Java 7.0.02 the <a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#readAllLines-java.nio.file.Path-"><code>Files.readAllLines()</code></a> method does raise a <code>NoSuchFileException</code>, though it's not explicitly documented to do so:</p>
  
  <pre><code>Files.readAllLines(Paths.get("foo"), StandardCharsets.UTF_8)
  </code></pre>
  
  <blockquote>
  <pre><code>java.nio.file.NoSuchFileException: foo
    at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
    at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
    at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
    at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:229)
    at java.nio.file.Files.newByteChannel(Files.java:315)
    at java.nio.file.Files.newByteChannel(Files.java:361)
    at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:380)
    at java.nio.file.Files.newInputStream(Files.java:106)
    at java.nio.file.Files.newBufferedReader(Files.java:2660)
    at java.nio.file.Files.readAllLines(Files.java:2993)
  </code></pre>
  </blockquote>