View html from archive using WebView

南楼画角 提交于 2019-12-25 18:41:53

问题


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


来源:https://stackoverflow.com/questions/16579816/view-html-from-archive-using-webview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!