I have zip-compressed file, which contains a set of html pages. I need to load html-pages from it. I need to redefine the mechanism of resolve of links. It is possible using WebView javafx?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
If I understand well your question. I'm guessing that you need to open html files.
I extracted the next code from javafx 2 tutorial from Oracle
WebView browser = new WebView();
WebEngine webEngine = browser.getEngine();
webEngine.load("http://mySite.com");
The load function takes a regular URL, so you can put a URL like
file:///C:/temp/test.html
and you will load an archive from your machine.
Hope it helps.
回答2:
Try using ZipFile
and ZipEntry
to retrieve your html documents from the .zip file as an InputStream
:
ZipFile zipFile = new ZipFile("path to your .zip");
ZipEntry zipEntry = new ZipEntry("name of your html file");
InputStream is = zipFile.getInputStream(zipEntry); //InputStream to your file