Ruby/File Directory/readline

Материал из Wiki.crossplatform.ru

Версия от 17:57, 13 сентября 2010; ViGOur (Обсуждение | вклад)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

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("|") }