Ruby/File Directory/each byte
Материал из Wiki.crossplatform.ru
Версия от 17:10, 26 мая 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 }