Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Ayumi, 1 invisible), 584 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[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 Offline OP
Expert
Xarthor  Offline 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!)
Code:
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] #325821
05/28/10 14:04
05/28/10 14:04
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
does the "file:///c:/..."-protocol work (instead of "http://...")?

Re: [Java] Displaying a local html file [Re: Joey] #325822
05/28/10 14:09
05/28/10 14:09
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline OP
Expert
Xarthor  Offline OP
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
@Joey: I guess it should but I'd rather like to pass a relativ path because the location of the application may change.

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 Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
According to Google, passing this shoud work:

Code:
file:///Manual/index.html



Last edited by Helghast; 05/28/10 14:55.

Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
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 Offline OP
Expert
Xarthor  Offline OP
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Quote:

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: Xarthor] #325866
05/28/10 18:23
05/28/10 18:23
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
yeah, well, you have to use the absolute path, that's why my sample starts with c:/

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 Offline
Senior Expert
Quad  Offline
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: Quad] #325904
05/28/10 21:03
05/28/10 21:03
Joined: Feb 2009
Posts: 2,154
Damocles_ Offline
Expert
Damocles_  Offline
Expert

Joined: Feb 2009
Posts: 2,154
try this one:

java.io.File currentDir = new java.io.File("");
System.out.println(currentDir.getAbsolutePath());

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 Offline OP
Expert
Xarthor  Offline OP
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Thanks a lot Damocles!
That worked great!

I used this snippet:
Code:
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_ Offline
Expert
Damocles_  Offline
Expert

Joined: Feb 2009
Posts: 2,154
cool, no problem


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1