• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

resourceBundle.getStringArray

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic