Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » URL and/or ClassLoader problem
URL and/or ClassLoader problem [message #443671] Thu, 02 February 2006 18:27 Go to next message
Paul E. Keyser is currently offline Paul E. KeyserFriend
Messages: 878
Registered: July 2009
Senior Member
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 21:04 Go to previous message
Paul E. Keyser is currently offline Paul E. KeyserFriend
Messages: 878
Registered: July 2009
Senior Member
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: Wed Oct 09 03:56:34 GMT 2024

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

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

Back to the top