Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created January 17, 2019 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/7eac8e390da9816719618ef4eff0c583 to your computer and use it in GitHub Desktop.
Save parzibyte/7eac8e390da9816719618ef4eff0c583 to your computer and use it in GitHub Desktop.
Leer archivo en pedazos created by parzibyte - https://repl.it/@parzibyte/Leer-archivo-en-pedazos
Hola, soy un archivo de texto para demostrar algunos tutoriales de parzibyte.me. Puedo contener cualquier tipo de contenido, por ejemplo, saltos,
tabulaciones
y cualquier
otra
cosa.
=begin
Leer archivos por bytes en Ruby
@author parzibyte
=end
NOMBRE_ARCHIVO = "archivo.txt"
BYTES_POR_LECTURA = 15
# Abrirlo en modo lectura
open(NOMBRE_ARCHIVO, "r") do |archivo|
# Mientras no se alcance el EOF, sigue leyendo e imprimiendo
until archivo.eof?
leido = archivo.read(BYTES_POR_LECTURA)
puts leido
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment