View Subcategory

Write a string to a file

ruby
File.new("a_file", "w") << "some text"

Append to a file

ruby
file = File.new('/tmp/test.txt', 'a+') ; file.puts 'This line appended to file!!' ; file.close()