Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » URL and/or ClassLoader problem
URL and/or ClassLoader problem [message #443671] Thu, 02 February 2006 13:27 Go to next message
Eclipse UserFriend
R3.1.1, WinXP

So, I have a valid URL, that points to a valid directory, in one of my RCP plugins, containing some
"resource" (readonly) files; its string rep looks like this:

file:/c:/LOCATION/eclipse/workspace/com.foo.bar.some.plugin/ subdirectory/txt

Now, I want to create from that URL a valid URL for a specific file in that directory, so I can read
it, e.g., by calling fileURL.openStream(), and using the InputStream. So, I try this, where
"validURL" is my URL as above:

new URL(validURL, "filename.ext");

That fails! It gives me a URL that is bogus, whose String-rep is:

file:/c:/LOCATION/eclipse/workspace/com.foo.bar.some.plugin/ subdirectory/filename.ext

What does work is this:

new URL(validURL, "txt/" + "filename.ext");

But hardwiring in that "txt/" is clearly a Bad Thing -- so what am I doing wrong here?

thanks,
Paul
Re: URL and/or ClassLoader problem [message #453662 is a reply to message #443671] Mon, 07 August 2006 17:04 Go to previous message
Eclipse UserFriend
Finally I stumbled across the answer, recorded here for others who may run into the issue:

I was using this code (where the "xyz/" is replacing the "removed" last segment of the file-path):

new URL(url, "xyz/" + docID)

I've just discovered that this is the correct code:

new URL(url.getProtocol(), url.getHost(), url.getPort(), url.getFile() + '/' + docID)

HTH,
Paul
Previous Topic:welcome view in java
Next Topic:How to invoke Eclipse operations?
Goto Forum:
  


Current Time: Thu Jul 17 05:59:28 EDT 2025

Powered by FUDForum. Page generated in 0.04919 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top