Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » RE: Access file in developed plugin
RE: Access file in developed plugin [message #330639] Wed, 06 August 2008 17:35 Go to next message
Mark Melia is currently offline Mark MeliaFriend
Messages: 142
Registered: July 2009
Senior Member
Hi all,

I have a little problem. I have developed a plugin, and in my plugin in
have an XML properties file. I need to be able to access this properties
file in my plugin code - to do this i need the file location. Does anyone
know how to do this?

Thanks for your help,
Mark
Re: Access file in developed plugin [message #330651 is a reply to message #330639] Thu, 07 August 2008 10:30 Go to previous messageGo to next message
Mark Melia is currently offline Mark MeliaFriend
Messages: 142
Registered: July 2009
Senior Member
Hi all,

I found this post
http://dev.eclipse.org/mhonarc/newsLists/news.eclipse.platfo rm/msg32261.html
, which outlines how to access a file in a plugin at runtime using an
InputStream. What I am trying to do is to define a build file and embed
that in the plugin and then call the ant programmatically using the
AntRunner. Unfortunately the AntRunner doesnt seem to work with an
InputStream representation of the build file - so does anyone know how to
either allow AntRunner to accept an InputStream as its buildfile (instead
of the file location) or know how to specify a file location for the build
file which is in the plugin jar at runtime?

Thanks for your help,
Mark

Mark Melia wrote:

> Hi all,

> I have a little problem. I have developed a plugin, and in my plugin in
> have an XML properties file. I need to be able to access this properties
> file in my plugin code - to do this i need the file location. Does anyone
> know how to do this?

> Thanks for your help,
> Mark
Re: Access file in developed plugin [message #330699 is a reply to message #330651] Sun, 10 August 2008 05:39 Go to previous message
Shawn Spiars is currently offline Shawn SpiarsFriend
Messages: 16
Registered: July 2009
Junior Member
Mark,

Maybe this method will help.

public static Properties getPropertiesFromPlugin(
String fileName, String pluginId) {

Properties properties = new Properties();

try {

Path path = new Path(fileName);
Bundle bundle = Platform.getBundle(pluginId);
InputStream propStream = FileLocator.openStream(bundle, path, false);
properties.load(propStream);
propStream.close();

} catch (IOException e) {
}

return properties;
}

Shawn
Phurnace Software

Mark Melia wrote:
> Hi all,
> I found this post
> http://dev.eclipse.org/mhonarc/newsLists/news.eclipse.platfo rm/msg32261.html
> , which outlines how to access a file in a plugin at runtime using an
> InputStream. What I am trying to do is to define a build file and embed
> that in the plugin and then call the ant programmatically using the
> AntRunner. Unfortunately the AntRunner doesnt seem to work with an
> InputStream representation of the build file - so does anyone know how
> to either allow AntRunner to accept an InputStream as its buildfile
> (instead of the file location) or know how to specify a file location
> for the build file which is in the plugin jar at runtime?
>
> Thanks for your help,
> Mark
>
> Mark Melia wrote:
>
>> Hi all,
>
>> I have a little problem. I have developed a plugin, and in my plugin
>> in have an XML properties file. I need to be able to access this
>> properties file in my plugin code - to do this i need the file
>> location. Does anyone know how to do this?
>
>> Thanks for your help,
>> Mark
>
>
Previous Topic:Purpose of default value for extension attribute
Next Topic:how to change editor font size
Goto Forum:
  


Current Time: Sat Nov 09 05:19:11 GMT 2024

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

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

Back to the top