This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Jessie Kensinger wrote:by looking at the documentation, it seems to me like FileNotFoundException alludes to failure to open a file, where NoSuchFileException could be applied in more general circumstances.
No, I think it's the other way around. The Java 7 exception NoSuchFileException is used only when the requested file does not exist; the earlier version FileNotFoundException was used for that and also for cases where the file does exist but can't be accessed for some reason. In Java 7 there is AccessDeniedException for the latter cases.
for people who are "lazy" and like to re-use built in exceptions, any thoughts or feelings as too why one would switch to using NoSuchFileException?
Perhaps the language designers decided that reusing exceptions was actually a bad thing (although being lazy is usually a good characteristic for a programmer). The old FileNotFoundException was even thrown when a URLConnection failed to access an HTTP resource -- this wasn't helpful when the exception was read by somebody who wasn't too clear on the difference between a file and a resource.