将文件名转换为 URL() 后发生 Java IO FileNotFoundException
这是 Jython 代码(尽管这可能不是 Jython 特定的问题)...
file_name = "Manifest.ttl"
file_url = File(file_name).toURL()
f = File(file_url.toString())
java.io.FileNotFoundException:java.io.FileNotFoundException: 文件:/home/james/projects/wordnet/wordnet30/rdf/Manifest.ttl(没有这样的 文件或目录)
Here is the Jython code (although this may not be a Jython-specific issue)...
file_name = "Manifest.ttl"
file_url = File(file_name).toURL()
f = File(file_url.toString())
java.io.FileNotFoundException: java.io.FileNotFoundException:
file:/home/james/projects/wordnet/wordnet30/rdf/Manifest.ttl (No such
file or directory)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

Javadoc 救援:
File 构造函数采用抽象路径名作为参数,而不是 URL 的 toString 表示形式。
此外,
toURL
已被弃用。您可以使用toURI
,并使用此 URI 重建文件。Javadoc to the rescue:
The File constructor takes an abstract path name as argument, not the toString representation of a URL.
Besides,
toURL
is deprecated. You might usetoURI
, and reconstruct the file with this URI.