print every fifth character in a file: : seek « File Directory « Ruby






print every fifth character in a file:


f = File.new("test.txt", "r")
while a = f.getc
  puts a.chr
  f.seek(5, IO::SEEK_CUR)
end

 








Related examples in the same category

1.position the file pointer 5 bytes from the end of the file and change the character to an X