英文:
How does newOutputStream method work in JAVA?
问题
这个函数在没有返回值的情况下如何工作?我想知道它的操作原理是什么。
英文:
While watching the package jdk.internal.jrtfs.JrtFileSystem class
final OutputStream newOutputStream(JrtPath jrtPath, OpenOption... options) throws IOException {
throw readOnly();
}
How does this function work when there is no return value?
I wonder what the principle of operation is.
enter image description here
答案1
得分: 1
readOnly 是同一个类中的一个静态方法。
static ReadOnlyFileSystemException readOnly() {
return new ReadOnlyFileSystemException();
}
因此,throw readOnly() 等同于 throw new ReadOnlyFileSystemException(),因为 readOnly 方法返回一个 Exception 实例。
英文:
readOnly is a static method in the same class.
static ReadOnlyFileSystemException readOnly() {
return new ReadOnlyFileSystemException();
}
Hence throw readOnly() is equivalent to throw new ReadOnlyFileSystemException() as readOnly method returns an instance of Exception.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论