From 1287bbeaaf2c21021ce5432b4fd094ea0426554d Mon Sep 17 00:00:00 2001 From: Juan Carlos Ballesteros Hermida Date: Sun, 6 Oct 2019 17:02:38 +0200 Subject: [PATCH] =?UTF-8?q?Fichero=20de=20prueba=20creado,=20y=20c=C3=B3di?= =?UTF-8?q?go=20para=20leer=20sus=20lineas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fichero.txt | 10 ++++++++++ .../java/org/tecnificados/com/lector/App.java | 19 ++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 fichero.txt diff --git a/fichero.txt b/fichero.txt new file mode 100644 index 0000000..0b669b6 --- /dev/null +++ b/fichero.txt @@ -0,0 +1,10 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 \ No newline at end of file diff --git a/src/main/java/org/tecnificados/com/lector/App.java b/src/main/java/org/tecnificados/com/lector/App.java index 51e4f55..5585ff5 100644 --- a/src/main/java/org/tecnificados/com/lector/App.java +++ b/src/main/java/org/tecnificados/com/lector/App.java @@ -1,13 +1,26 @@ package org.tecnificados.com.lector; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.io.FileUtils; + /** - * Hello world! - * + * Lector de ficheros linea a linea */ public class App { public static void main( String[] args ) { - System.out.println( "Hello World!" ); + List readedLines = new ArrayList(); + try { + readedLines = FileUtils.readLines(new File("fichero.txt"),"utf-8"); + System.out.println("Lineas: "+readedLines.size()); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } }