写:
File.open('test.rb','w') do |f2|
f2.puts "This is a test \n Good day"
end
读:
File.open('test.rb','r') do |f1|
while line=f1.gets
puts line
注:r只读 r+读写 w只写,覆盖原文件或创建一个新文件