2013-05-16 34 views
0

我有zip压缩文件,其中包含一组html页面。我需要从中加载html页面。我需要重新定义链接的解决机制。有可能使用WebView javafx?使用WebView从档案中查看html

+1

什么样的档案?它在哪里相对于您的应用程序代码?你如何部署应用程序代码和存档? – jewelsea

回答

0

如果我理解你的问题。我猜你需要打开html文件。

我提取的下一个代码从javafx 2 tutorial from Oracle

WebView browser = new WebView(); 
WebEngine webEngine = browser.getEngine(); 
webEngine.load("http://mySite.com"); 

负载的功能需要一个正规的网址,所以你可以把一个URL像

file:///C:/temp/test.html 

,你会从你的机器加载存档。

希望它有帮助。

0

尝试使用ZipFileZipEntry从.zip文件检索您的HTML文档作为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 
+0

优雅的解决方案,谢谢SilverMonkey –