Page 1 of 1

Properties files in a plugin

PostPosted: Thu Apr 27, 2006 7:35 am
by Andrew VanderVelde
I'm using MD 9.5 and would like to use a properties file with my plugin. I
would get an error that it could not be located when I tried to use one. Is
there anything special I need to do to enable the use of a properties file?
Do I need to include it in the plugin.xml? Does MD have a library to read
properties files or do I need to do that? Thanks for your help.



Re: Properties files in a plugin

PostPosted: Fri Apr 28, 2006 6:53 am
by Tomas Pugzlys
Hello,

> Do I need to include it in the plugin.xml?
You may use your plugin classloader to load your properties file.

For example if your property file is located in your plugin directory:
InputStream stream = getClass().getResourceAsStream("your.properties");
Properties prop = new Properties();
prop.load(stream);

If your property file is in your plugin jar:
InputStream stream =
getClass().getResourceAsStream("/com/your/plugin/packages/your.properties");
...

Regards,
--
Tomas Pugzlys
Programmer
No Magic Lithuanian Development Center
Savanoriu pr. 363- IV, LT-49425, Kaunas
P.O. box 2166, LT-44011, Kaunas
Phone: +370 37 324032 Fax: +370 37 320670
e-mail : tomasp
WWW: http://www.magicdraw.com
--
MagicDraw - UML Made Simple

nntp://news.nomagic.com/nomagic.products.magicdrawuml.openapi wrote:
> I'm using MD 9.5 and would like to use a properties file with my plugin. I
> would get an error that it could not be located when I tried to use one. Is
> there anything special I need to do to enable the use of a properties file?
> Do I need to include it in the plugin.xml? Does MD have a library to read
> properties files or do I need to do that? Thanks for your help.
>