Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (492)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
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 1133 times)
0 Members and 1 Guest are viewing this topic.
Offline chisser98

Senior Newbie




Java games rock!


« Posted 2004-04-26 00: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 01: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 12: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!
Legends of Yore - The Casual Retro Roguelike
Offline chisser98

Senior Newbie




Java games rock!


« Reply #3 - Posted 2004-04-26 14: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.

 

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

The first screenshot will be displayed as a thumbnail.

Nickropheliac (16 views)
2014-08-31 22:59:12

TehJavaDev (24 views)
2014-08-28 18:26:30

CopyableCougar4 (33 views)
2014-08-22 19:31:30

atombrot (42 views)
2014-08-19 09:29:53

Tekkerue (41 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (26 views)
2014-08-16 06:20:21

Tekkerue (37 views)
2014-08-16 06:12:11

Rayexar (73 views)
2014-08-11 02:49:23

BurntPizza (49 views)
2014-08-09 21:09:32
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
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!