Skip to content

Instantly share code, notes, and snippets.

Created December 12, 2012 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/a0f7c2c64ac8348c34d5 to your computer and use it in GitHub Desktop.
Save anonymous/a0f7c2c64ac8348c34d5 to your computer and use it in GitHub Desktop.
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