Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Accessing plugin data
Accessing plugin data [message #302641] Wed, 26 April 2006 04:42 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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
Previous Topic:Set a editor to non-editable
Next Topic:LaunchConfiguration
Goto Forum:
  


Current Time: Mon Jul 21 22:01:39 EDT 2025

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

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

Back to the top