[opencms-dev] .properties file
Dudu Zoltan
dzoltan at gmail.com
Mon Jun 30 15:41:34 CEST 2014
Thank you!
It worked
On Mon, Jun 30, 2014 at 4:20 PM, Kai Widmann <Widmann at mediaworx.com> wrote:
> Hi,
>
>
>
> sure that’s possible. Since classes are usually exported to
> WEB-INF/classes/… you could either get the properties file from the real
> file system or you could use the class loader to access the properties file.
>
> Here’s an example for using the class loader:
>
>
>
> public class ContentTypeConfiguration {
>
>
>
> private static final Log LOG =
> LogFactory.getLog(ContentTypeConfiguration.class);
>
> private static final String PROPSPATH =
> "com/mediaworx/b4f/opencms/contenttypes/ContentTypeConfig.properties";
>
>
>
> private static final Properties prop;
>
>
>
> static {
>
> prop = new Properties();
>
> try {
>
>
> prop.load(ContentTypeConfiguration.class.getClassLoader().getResourceAsStream(PROPSPATH));
>
> }
>
> catch (IOException e) {
>
> LOG.error(PROPSPATH + " could not be loaded.");
>
> }
>
> }
>
>
>
> [...]
>
> }
>
>
>
>
>
> I’m sure there are other ways (e.g. ResourceBundle), but this has worked
> for me so far.
>
>
>
> Cheers
>
>
>
> Kai
>
>
>
> *Von:* opencms-dev-bounces at opencms.org [mailto:
> opencms-dev-bounces at opencms.org] *Im Auftrag von *Dudu Zoltan
> *Gesendet:* Montag, 30. Juni 2014 15:13
> *An:* The OpenCms mailing list
> *Betreff:* [opencms-dev] .properties file
>
>
>
> Hi,
>
>
>
> Is it possible to read a .properties file from within a module.
>
> So, for instance, if I have a module com.myexample.mymodule with an action
> class MyAction.class and a mymodule.properties file, is it possible to read
> the .properties file from the action class?
>
>
>
> accessing the file by name only (they are on the same path) does not work
> and accessing by
> '/system/modules/com.myexample.mymodule/classes/com/myexample/mymodule/mymodule.properties'
> does not work also.
>
>
>
> thanks.
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20140630/49291273/attachment.htm>
More information about the opencms-dev
mailing list