Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

resourceBundle.getStringArray

 
Marc Gravel
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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):

title={"value1","value2","value3",""}

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(","));
-with-
title=value1,value2,value3,

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

Thanks in advance for your comments.

Marc
 
Kevin Kovach
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks.

- Kevin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic