Ruby/File Directory/readline
Материал из Wiki.crossplatform.ru
readline raises an EOFError when it reaches the end of the file.
file = File.new( "yourFile.txt" ) file.readline file.readline file.readline
Readlines by
open("pipe_separated_records", "w") do |f| f << "This is record one.|This is record two.|This is record three." end open("pipe_separated_records") { |f| f.readlines("|") }