|
[solved][Java] Displaying a local html file
#325820
05/28/10 14:00
05/28/10 14:00
|
Joined: Jul 2002
Posts: 4,436 Germany, Luebeck
Xarthor
OP
Expert
|
OP
Expert
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
|
Good day! I got a "fast" question about a problem I'm currently unable to solve: I'd like to display a html file in a Java application. Displaying a html file from an url (such as http://www.google.com) works, but my html file is a local one. Its locate in the project's subfolder "Manual". Which "url" do I pass to the JEditorPane's setPage method to display the index.html file (Manual/index.html) ? Any help is appreciated! Thanks in advance! edit: Solution: (Thanks to damocles!)
String manualFile = "file://";
java.io.File currentDir = new java.io.File("Manual/index.html");
manualFile += currentDir.getAbsolutePath();
Last edited by Xarthor; 05/29/10 08:04. Reason: problem solved
|
|
|
Re: [Java] Displaying a local html file
[Re: Xarthor]
#325829
05/28/10 14:55
05/28/10 14:55
|
Joined: Jan 2004
Posts: 3,023 The Netherlands
Helghast
Expert
|
Expert
Joined: Jan 2004
Posts: 3,023
The Netherlands
|
According to Google, passing this shoud work:
file:///Manual/index.html
Last edited by Helghast; 05/28/10 14:55.
|
|
|
Re: [Java] Displaying a local html file
[Re: Helghast]
#325831
05/28/10 15:06
05/28/10 15:06
|
Joined: Jul 2002
Posts: 4,436 Germany, Luebeck
Xarthor
OP
Expert
|
OP
Expert
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
|
java.io.FileNotFoundException: /Manual/index.html (No such file or directory)
I'm sorry Helghast, it doesn't work. But thanks for the suggestion!
|
|
|
Re: [Java] Displaying a local html file
[Re: Joey]
#325870
05/28/10 19:05
05/28/10 19:05
|
Joined: Oct 2007
Posts: 5,210 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
|
isn't tehre a function in java that let's you get the program path?
3333333333
|
|
|
Re: [Java] Displaying a local html file
[Re: Damocles_]
#325934
05/29/10 08:03
05/29/10 08:03
|
Joined: Jul 2002
Posts: 4,436 Germany, Luebeck
Xarthor
OP
Expert
|
OP
Expert
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
|
Thanks a lot Damocles! That worked great! I used this snippet:
String manualFile = "file://";
java.io.File currentDir = new java.io.File("Manual/index.html");
manualFile += currentDir.getAbsolutePath();
|
|
|
Re: [Java] Displaying a local html file
[Re: Xarthor]
#326110
05/30/10 13:32
05/30/10 13:32
|
Joined: Feb 2009
Posts: 2,154
Damocles_
Expert
|
Expert
Joined: Feb 2009
Posts: 2,154
|
|
|
|
|