Method: Properties#save

Defined in:
lib/xproperties/properties.rb

#save(file_name) ⇒ NilClass

Saves a property list(key and element pairs) to the .properties file. The file will be written in ISO-8859-1(Latin1) character encoding.

Parameters:

  • file_name

    .properties file name.

Returns:

  • (NilClass)

Raises:

  • IOError When an error occurs while writing the file.



585
586
587
588
589
590
591
592
593
594
595
# File 'lib/xproperties/properties.rb', line 585

def save(file_name)
  file = File.open file_name, "w", :encoding => "iso-8859-1"
  @properties.each_pair do |k, v|
    key = save_convert k, :is_convert_key => true
    value = save_convert v
    pair = key + "=" + value
    file.write pair + "\n"
  end
  file.close
  nil?
end