my dog learned polymorphism
The moose likes Beginning Java and the fly likes resourceBundle.getStringArray Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "resourceBundle.getStringArray" Watch "resourceBundle.getStringArray" New topic


Marc Gravel

Joined: May 25, 2005
Posts: 1
I'm trying to define a string array in my resource bundle to retrieve it like this:

ResourceBundle bundle = ResourceBundle.getBundle("ApplicationResources");

String[] stringArray = bundle.getStringArray("title");

How do I specify an array of values in a properties file to retrieve it this way? Defining it this way has not worked (CastClassException):


Is this even a good way to do it? I have a goofy work around method, but there has to be something better:

String[] stringArray = (bundle.getString("title").split(","));

... the problem is with the trailing ","; it produces a one space char instead of none (i.e., " " vs. "").

Thanks in advance for your comments.

Kevin Kovach

Joined: Oct 17, 2005
Posts: 5
I've been searching the web for the answer to this question for the past couple hours. I've seen several threads but they all end the same way. Without an answer and the original poster ending up using some kind of tokenizer instead.

This is very confusing to me. I'd have thought this was something that somebody would have a quick answer for. Maybe this is not a very common usage, but it seemed like a decent solution to me.

I'd really appreciate a response from anyone knowing the correct format of the properties file and usage of the ResourceBundle.getStringArray() method.


- Kevin
I agree. Here's the link:
subject: resourceBundle.getStringArray
jQuery in Action, 3rd edition