Accessing plugin data [message #302641] |
Wed, 26 April 2006 04:42  |
Eclipse User |
|
|
|
Originally posted by: address.starts.after.hyphen-martin.umgeher.joanneum.at
Hello,
how can I access files that are stored relative to my plug-in's
directory? For images, this works with
AbstractUIPlugin.imageDescriptorFromPlugin. But for other files (in my
case, an XSL file), I could only find Plugin.getBundle.getResource,
which returns a URL with the protocoll "bundleresource://", and I don't
know what to do with that.
Thanks,
M
|
|
|
Re: Accessing plugin data [message #302650 is a reply to message #302641] |
Wed, 26 April 2006 09:51   |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
You would use url.openStream() to get the input stream for the file for
usages that can't take just a URL.
This is the best way to access it. However if you are using some other
code that will only take a local java.io.File or a fully-qualified local
file name and will not accept a URL or an InputStream, then you would
need to also do:
String filename = FileLocator.toFileURL(url).getFile();
However, be careful with this because if your plugin is within a jar or
not a local file then this will make a physical copy of the jar on your
local file system. Unless it is exactly what you want don't do this with
a directory. If it is within a jar'ed plugin the ENTIRE directory will
be pulled out of the jar and placed on the local file system.
martin wrote:
> Hello,
>
> how can I access files that are stored relative to my plug-in's
> directory? For images, this works with
> AbstractUIPlugin.imageDescriptorFromPlugin. But for other files (in my
> case, an XSL file), I could only find Plugin.getBundle.getResource,
> which returns a URL with the protocoll "bundleresource://", and I don't
> know what to do with that.
>
> Thanks,
> M
--
Thanks,
Rich Kulp
|
|
|
Re: Accessing plugin data [message #302658 is a reply to message #302650] |
Wed, 26 April 2006 13:01  |
Eclipse User |
|
|
|
Originally posted by: address.starts.after.hyphen-martin.umgeher.joanneum.at
Rich Kulp wrote:
> You would use url.openStream() to get the input stream for the file for
> usages that can't take just a URL.
>
> This is the best way to access it. However if you are using some other
> code that will only take a local java.io.File or a fully-qualified local
> file name and will not accept a URL or an InputStream, then you would
> need to also do:
>
> String filename = FileLocator.toFileURL(url).getFile();
>
> However, be careful with this because if your plugin is within a jar or
> not a local file then this will make a physical copy of the jar on your
> local file system. Unless it is exactly what you want don't do this with
> a directory. If it is within a jar'ed plugin the ENTIRE directory will
> be pulled out of the jar and placed on the local file system.
>
> martin wrote:
>> Hello,
>>
>> how can I access files that are stored relative to my plug-in's
>> directory? For images, this works with
>> AbstractUIPlugin.imageDescriptorFromPlugin. But for other files (in my
>> case, an XSL file), I could only find Plugin.getBundle.getResource,
>> which returns a URL with the protocoll "bundleresource://", and I
>> don't know what to do with that.
>>
>> Thanks,
>> M
>
Thanks a lot, that did it :)
M
|
|
|
Powered by
FUDForum. Page generated in 0.06999 seconds