String to String array

I have a property file with the following content:

property1 = ["one","two","three"]

property2 = [ ["a","b","c" ], ["d","e"] ]

I want to convert this into java objects:

String[] property1;

String[][] property2;

How should I do this?

[481 byte] By [me97esna] at [2007-11-26 18:52:44]
# 1
With recursive use of String.split(), I'd say. Will be brittle, though, because you have a potential problem with the unknown number of dimensions. You can't handle that dynamically.
CeciNEstPasUnProgrammeura at 2007-7-9 6:26:47 > top of Java-index,Java Essentials,Java Programming...
# 2
Why do you need two-dimensional properties, by the way? Maybe there's an alternative.
CeciNEstPasUnProgrammeura at 2007-7-9 6:26:47 > top of Java-index,Java Essentials,Java Programming...
# 3

I'm thinking about using java6 with jRuby. But I thought there might be a more dynamic way of doing it:

ScriptEngine rubyEngine = new ScriptEngineManager().getEngineByName("jruby");

Object object = rubyEngine.eval(theStringFromPropFile, rubyEngine.getContext());

RubyArray array = (RubyArray) object; // 2-d array

List<RubyArray> list = array.getList();

List<String> list1 = list.get(0).getList(); // String array

List<String> list2 = list.get(1).getList(); // String array

me97esna at 2007-7-9 6:26:47 > top of Java-index,Java Essentials,Java Programming...
# 4
I need to read a two dimensional array because there is another application (written in Ruby) which produces the propertyfile, and it has this format.
me97esna at 2007-7-9 6:26:47 > top of Java-index,Java Essentials,Java Programming...
# 5
why don't you use a List of String[]? it would be easier to create a String[] []...
suparenoa at 2007-7-9 6:26:47 > top of Java-index,Java Essentials,Java Programming...