有人知道“可选特定异常”到底是什么意思吗?
https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html
有些 JVM 会抛出它,有些则不会?如果他们不这样做,向他们抛出一般的 IOException 或根本没有异常?如果有关于不同实现的统计数据,它到底有多“可选”?
最佳答案
摘自 Jeff Friesen 的《Java I/O、NIO 和 NIO.2》一书:
FileAlreadyExistsException
is an example of an optional specific exception. It's optional because it's thrown when the underlying operating system can detect the specific error leading to the exception. If the error cannot be detected, itsIOException
ancestor is thrown instead.
关于java - 类 java.nio.file.Files 抛出 FileAlreadyExistsException 作为 "optional specific exception"。这是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58232591/