Skip to content

anonymous /jruby_properties_example.rb secret

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
require 'java'
java_import 'java.util.Properties'
java_import 'java.io.FileInputStream'
def get_properties_from_file
File.write('colors.properties', 'colors.pie=#FF0000, #00FF00, #0000FF')
props = Properties.new
fileInput = FileInputStream.new("/Users/keithb/work/temp/colors.properties")
props.load(fileInput)
fileInput.close
props
end
# def create_properties
# props = Properties.new
# props['colors.pie'] = '#FF0000, #00FF00, #0000FF'
# props
# end
# x = create_properties['foo']
props = get_properties_from_file
colors_pie = props.getProperty('colors.pie')
p colors_pie.class
p colors_pie
colors_pie = props['colors.pie']
p colors_pie.class
p colors_pie
# Output:
# String
# "#FF0000, #00FF00, #0000FF"
# String
# "#FF0000, #00FF00, #0000FF"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.