{"id":83,"date":"2013-12-14T21:26:20","date_gmt":"2013-12-14T21:29:21","guid":{"rendered":"https:\/\/f2c7bmultiple-read-write-object.png"},"modified":"2015-07-16T19:20:12","modified_gmt":"2015-07-17T01:20:12","slug":"como-leer-un-archivo-de-texto-en-java","status":"publish","type":"post","link":"https:\/\/emanuelpaxtian.com\/blog\/como-leer-un-archivo-de-texto-en-java\/","title":{"rendered":"Como leer un archivo de texto en Java"},"content":{"rendered":"<p>En el siguiente ejemplo se muestra como leer un archivo de texto utilizando Java<\/p>\n<p>El archivo se lee l\u00ednea por l\u00ednea, y a medida que avanza la lectura se imprimen la l\u00edneas por pantalla.<\/p>\n<pre class=\"brush:java\">import java.io.*;\r\nclass LeerArchivo  {\r\n    public static void main(String args[]) {\r\n        try{\r\n            \/\/ Abrimos el archivo\r\n            FileInputStream fstream = new FileInputStream(\"LeerArchivo.java\");\r\n            \/\/ Creamos el objeto de entrada\r\n            DataInputStream entrada = new DataInputStream(fstream);\r\n            \/\/ Creamos el Buffer de Lectura\r\n            BufferedReader buffer = new BufferedReader(new InputStreamReader(entrada));\r\n            String strLinea;\r\n            \/\/ Leer el archivo linea por linea\r\n            while ((strLinea = buffer.readLine()) != null)   {\r\n                \/\/ Imprimimos la l\u00ednea por pantalla\r\n                System.out.println (strLinea);\r\n            }\r\n            \/\/ Cerramos el archivo\r\n            entrada.close();\r\n        }catch (Exception e){ \/\/Catch de excepciones\r\n            System.err.println(\"Ocurrio un error: \" + e.getMessage());\r\n        }\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>En el siguiente ejemplo se muestra como leer un archivo de texto utilizando Java El archivo se lee l\u00ednea por l\u00ednea, y a medida que avanza la lectura se imprimen&hellip;<\/p>\n","protected":false},"author":1,"featured_media":705,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-83","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/posts\/83","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/comments?post=83"}],"version-history":[{"count":0,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/posts\/83\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/media\/705"}],"wp:attachment":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/media?parent=83"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/categories?post=83"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/tags?post=83"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}