Class java.nio.file.Files 将 FileAlreadyExistsException 抛出为 "optional specific exception"。这是什么意思?
Class java.nio.file.Files throws FileAlreadyExistsException as "optional specific exception". What does it mean?
有人知道 "optional specific exception" 到底是什么意思吗?
https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html
有些 JVM 会抛出它,有些则不会?如果他们不这样做,向他们抛出一般的 IOException 或根本没有异常?它有一个关于不同实现的统计数据,"optional" 究竟如何?
来自 Jeff Friesen 的书 "Java I/O, NIO and 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, its IOException
ancestor is thrown instead.
有人知道 "optional specific exception" 到底是什么意思吗?
https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html
有些 JVM 会抛出它,有些则不会?如果他们不这样做,向他们抛出一般的 IOException 或根本没有异常?它有一个关于不同实现的统计数据,"optional" 究竟如何?
来自 Jeff Friesen 的书 "Java I/O, NIO and 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.