0
我正在尝试使用java中的URL读取文件。使用URL读取文件
FileHelper.read(new File(getClass.getResource("TextFile.rtf")))
我对下面的异常
error: overloaded method constructor File with alternatives:
(java.net.URI)java.io.File <and>
(java.lang.String)java.io.File
cannot be applied to (java.net.URL)
任何想法或建议,我怎么能解决这个例外真糊涂。
谢谢!
did you mean'getClass()。getResource(“TextFile.rtf”);'? –
“File”类将“URI”而不是“URL”作为参数。 'getResource()'返回一个'URL'。 –
将我的帖子更新为网址。 – user1993412