<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Danny's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 21 Aug 2008 13:34:32 GMT</pubDate>
    <description>DZone Snippets: Danny's Code Snippets</description>
    <item>
      <title>Load properties from properties file into Hash</title>
      <link>http://snippets.dzone.com/posts/show/1311</link>
      <description>Loads properties from a file with lines formatted as 'key=value' into a Hash. Comments (lines starting with #) are skipped, as are lines starting with =. Empty property values (lines ending with =) and property values containing = are included in the Hash.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  def load_properties(properties_filename)&lt;br /&gt;    properties = {}&lt;br /&gt;    File.open(properties_filename, 'r') do |properties_file|&lt;br /&gt;      properties_file.read.each_line do |line|&lt;br /&gt;        line.strip!&lt;br /&gt;        if (line[0] != ?# and line[0] != ?=)&lt;br /&gt;          i = line.index('=')&lt;br /&gt;          if (i)&lt;br /&gt;            properties[line[0..i - 1].strip] = line[i + 1..-1].strip&lt;br /&gt;          else&lt;br /&gt;            properties[line] = ''&lt;br /&gt;          end&lt;br /&gt;        end&lt;br /&gt;      end      &lt;br /&gt;    end&lt;br /&gt;    properties&lt;br /&gt;  end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 29 Jan 2006 16:59:55 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1311</guid>
      <author>danny (Danny Lagrouw)</author>
    </item>
  </channel>
</rss>
