[英]use html file from jar in java
I want to add html files to jar files and access them through jar in the windows application project how can i access them I am using the following code . 我想将html文件添加到jar文件并通过Windows应用程序项目中的jar访问它们如何访问它们我使用以下代码。
try{
File f1= new File(getClass.getResource("/path is the src folder/));
}
but it is showing no suitable constructor found 但它没有找到合适的构造函数
File
won't take a URL
as reference. File
不会将URL
作为参考。 Embedded resources like this aren't actually files, they are InputStream
s to the resource. 像这样的嵌入式资源实际上不是文件,它们是资源的
InputStream
。
Depending on how you're showing them will determine what you need to do. 根据您展示它们的方式,将决定您需要做什么。
For example, JEditorPane
takes a URL
via its setPage
method 例如,
JEditorPane
通过其setPage
方法获取URL
UPDATED 更新
You should be able to load the pages directly into the editor pane using something like... 您应该能够使用类似的东西将页面直接加载到编辑器窗格中。
// editor pane is a reference to a JEditorPane
editorPane.setPage(getClass.getResource("/path is the src folder/"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.