Hi, I'm trying to read .properties file using JRuby, calling the java classes. The problem is if there are comma separated values in the property file, it fetches only the first value. For example, say I have a line like "type=abc,cde" in the property file. The output of "puts prop.get_property("type")" returns only the first value (abc) and the not 2nd value. Below is my code: require 'java' include_class 'java.util.Properties' include_class 'java.io.FileInputStream' def read_prop_file prop = Properties.new fileInput = FileInputStream.new("E:\\test\\test.properties") prop.load(fileInput) fileInput.close puts prop.get_property("type") puts prop.get_property("module_names") end Am I doing anything wrong here? how can we retrive all the values related to a property? Thanks
on 2012-12-12 12:37
on 2012-12-12 13:16
Hi, Why don't you test with the same code, but in Java instead ? Does it return all values, or again the first one ? A good approach to make this work would be to first polish the details in pure Java, and then coding it in JRuby. Best Regards, Krum.
on 2012-12-12 16:41
I tried it and got the full string as a value. Can you try the script I posted at https://gist.github.com/a0f7c2c64ac8348c34d5 (changing the filespec of course) and see what you get? - Keith --- Keith R. Bennett http://about.me/keithrbennett
on 2012-12-13 04:19
Thanks for the responses. Keith, I tried your code and it works. Thank you!