Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (408)
games submitted by our members
Games in WIP (293)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Create a URL pointing to C:\  (Read 1003 times)
0 Members and 1 Guest are viewing this topic.
Offline chisser98

Senior Newbie




Java games rock!


« Posted 2004-04-26 02:59:07 »

Hey all!

How would I go about creating a URL that references to html files on my hard-drive?  I've tried to create a new URL object and sending the constructor strings like "file://C:/test.html", "file://C:\test.html", and "c:\test.html" but none of them seem to work.  

Heres the
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
package CarringtonPlace.Help;
import CarringtonPlace.IView.IBEIView;
import CarringtonPlace.Model.HelpBook;
import CarringtonPlace.Model.Constants;

import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.UIManager;

import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeSelectionModel;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;

import java.io.File;

import java.net.URL;
import java.io.IOException;
import java.awt.Dimension;
import java.awt.GridLayout;


/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */


public class HelpHTMLPane extends JEditorPane implements IBEIView
{  private HelpBook model;

   private URL helpURL;

   public HelpHTMLPane(HelpBook theModel)
   {  super();
      this.model = theModel;
     
      this.initializeHelp();
     
     
      this.model.addView(this);
   }
   
   private void initializeHelp()
   {  //String s = "http://www.icebreakersentertainment.com";
     //String s = "file://" + Constants.HELP_PATH + "test.html";
     //String s = "test.html";
     String s = "file://C:/test.html";
      //System.out.println(s);
     
      try
      {  this.helpURL = new URL(s);
      } catch (Exception e)
      {  System.err.println("Could not parse URL address.");
      }
     
      //this.helpURL = HelpHTMLPane.class.getResource("Main.html");
     if (helpURL == null)
      {  System.err.println("Couldn't open help file: " + s);
      } else
      {  System.out.println("Help URL is " + this.helpURL);
      }
     
      this.displayURL(helpURL);
   }
   
   private void displayURL(URL url)
   {  try
      {  if (url != null)
         {  this.setPage(url);
         } else
         {  //null url
           this.setText("File Not Found");
            System.out.println("Attempted to display a null URL.");
         }
      } catch (IOException e)
      {  System.err.println("Attempted to read a bad URL: " + url);
      }
   }

   
   public void updateView()
   {
   }
   
   public void updateColors()
   {
   }

}


I'd appreciate any input on this!

Thx,

Jarrett
aka. Chisser98
Offline chisser98

Senior Newbie




Java games rock!


« Reply #1 - Posted 2004-04-26 03:15:00 »

OHH MANN....I just figured it out.  Its one of those things that when you've got it you want to rip your hair out and scream "Gimme a break!".  

All I need to do was change "file://c:/test.html" to "file:///c:/test.html" !  I needed an extra "/" after the "file://"......ohhhh maann...lol!

I hope this helps someone else if they have this problem!

Regards,
Jarrett
aka. Chisser98
Offline sugarshark

Junior Member




Sugar to the sharks.


« Reply #2 - Posted 2004-04-26 14:48:01 »

In case you are still wondering why this is so:

An URL consists of <protocol>://<hostname>/<pathspec>.
An URL of the form file:/// has an empty hostname part, meaning localhost, that's all.

I used to think that the brain was the most wonderful organ in my body.  
Then I realized who was telling me this.
-- Emo Phillips
Games published by our own members! Check 'em out!
Try the Free Demo of Titan Attacks
Offline chisser98

Senior Newbie




Java games rock!


« Reply #3 - Posted 2004-04-26 16:19:31 »

Ahh ok.  That makes sense.  Thank you for the clarification.

Regards,
Jarrett
aka. Chisser98
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (130 views)
2013-05-17 21:29:12

alaslipknot (139 views)
2013-05-16 21:24:48

gouessej (169 views)
2013-05-16 00:53:38

gouessej (162 views)
2013-05-16 00:17:58

theagentd (173 views)
2013-05-15 15:01:13

theagentd (158 views)
2013-05-15 15:00:54

StreetDoggy (202 views)
2013-05-14 15:56:26

kutucuk (226 views)
2013-05-12 17:10:36

kutucuk (225 views)
2013-05-12 15:36:09

UnluckyDevil (229 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.173 seconds with 20 queries.