secret
Last active

  • Download Gist
jruby_properties_example.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
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"

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.