Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Initialising ResourceBundles in different dir:

Reply
Thread Tools

Initialising ResourceBundles in different dir:

 
 
t12be
Guest
Posts: n/a
 
      05-10-2004
Need help,

Is it possible to initialise a ResourceBundle from another dir?
In the example beneath this file has to be within the same dir of the
source files. I would like to seperate them, how?

ResourceBundle lang = ResourceBundle.getBundle("langBundle",new
Locale("en","US"));

I looked through the API and didn't find anything.
 
Reply With Quote
 
 
 
 
=?UTF-8?b?TMSByrtpZSBUZWNoaWU=?=
Guest
Posts: n/a
 
      05-10-2004
On Mon, 10 May 2004 08:44:17 -0700, t12be wrote:

> Need help,
>
> Is it possible to initialise a ResourceBundle from another dir? In the
> example beneath this file has to be within the same dir of the source
> files. I would like to seperate them, how?
>
> ResourceBundle lang = ResourceBundle.getBundle("langBundle",new
> Locale("en","US"));
>
> I looked through the API and didn't find anything.


You can pass in a ClassLoader to the getBundle() method. This ClassLoader
will determine where ResourceBundle will search for the bundle.
URLClassLoader will best serve your needs.

HTH,
La'ie Techie


 
Reply With Quote
 
 
 
 
t12be
Guest
Posts: n/a
 
      05-14-2004
L??ie Techie <laie@wing_this_etsolutions.com> wrote in message news:<(E-Mail Removed) ws.com>...
> On Mon, 10 May 2004 08:44:17 -0700, t12be wrote:
>
> > Need help,
> >
> > Is it possible to initialise a ResourceBundle from another dir?
> >...


>
> You can pass in a ClassLoader to the getBundle() method. This ClassLoader
> will determine where ResourceBundle will search for the bundle.
> URLClassLoader will best serve your needs.
>...


First of all thanks of the answer. Only I didn't get out of it. Looked
op how the URLCLassloader works but couldn't get it working. Maybe you
can help me on?

Have the following situation:
+++++++++++++++++++++++++++++
ResourceBundle lang = ResourceBundle.getBundle("langBundle",new
Locale("en","US"));

And the 'langBundle' files are in this dir (relative from src dir)
"../props/"
So I tried the following:
+++++++++++++++++++++++++
URL[] urls = new URL[1];
urls[0] = new URL("../props/");
ResourceBundle lang = ResourceBundle.getBundle("langBundle",new
Locale("en","US"), new URLClassLoader(urls));

Wich didn't work. Has it something to do with the relative url?? Read
something like using relative urls like the need to get a base for the
url by code like this: NameOfClass.class.getResource("")

thx
t12be
 
Reply With Quote
 
Michael Borgwardt
Guest
Posts: n/a
 
      05-14-2004
t12be wrote:
> So I tried the following:
> +++++++++++++++++++++++++
> URL[] urls = new URL[1];
> urls[0] = new URL("../props/");
> ResourceBundle lang = ResourceBundle.getBundle("langBundle",new
> Locale("en","US"), new URLClassLoader(urls));
>
> Wich didn't work. Has it something to do with the relative url??


What URL? "../props/" is a path, not an URL. You have to prepend it
with "file:", maybe add some slashes.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ResourceBundles - how to locate on Orion Fred Flintstone Java 7 09-05-2004 12:44 AM
Dynamic user control loading/initialising Jo Inferis ASP .Net 0 06-20-2004 12:51 PM
Using ResourceBundles in diff dir: t12be Java 0 05-02-2004 03:09 PM
Initialising a signal jan VHDL 3 12-23-2003 01:25 PM
ResourceBundles: Let user change UI language? Andreas Schmidt Java 0 11-07-2003 04:47 AM



Advertisments