Ruby/File Directory/each byte
Материал из Wiki.crossplatform.ru
(Различия между версиями)
ViGOur (Обсуждение | вклад) м (1 версия: Импорт выборки материалов по Ruby) |
Текущая версия на 17:57, 13 сентября 2010
Count bytes
file = File.new("myfile") e_count = 0 file.each_byte do |byte| e_count += 1 if byte == ?e end
each_byte is always associated with a block.
file5 = File.new("C:\\Ruby\\Sample") file5.each_byte{|ch| putc ch}
read an I/O stream byte by byte with each_byte:
File.open("text.txt").each_byte { |byte| puts byte }