Problem in reading the .properties file in JRuby


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 ‘’

def read_prop_file

    prop =

    fileInput ="E:\\test\\")

    puts prop.get_property("type")
    puts prop.get_property("module_names")


Am I doing anything wrong here? how can we retrive all the values
related to a property?



Why don’t you test with the same code, but in Java instead ? Does it
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

Best Regards,

I tried it and got the full string as a value. Can you try the script I
posted at (changing the
filespec of course) and see what you get?

  • Keith

Keith R. Bennett

Thanks for the responses. Keith, I tried your code and it works. Thank

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs