Created
January 17, 2019 16:04
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=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