2013-05-16 33 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 –