Ruby 读取文件

Ruby 读取文件

一次全读出来

textAll = File.read("fileName.txt")

puts textAll

一次读取一行

file = File.open("fileName.txt")

file.each_line {|line|

    puts line

}

file.close

原文地址:https://www.cnblogs.com/stono/p/6666077.html