pablosotol

Tarea2

Jun 7th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.28 KB | None | 0 0
  1. package implementacion;
  2.  
  3.  
  4. import java.io.BufferedReader;
  5. import java.io.File;
  6. import java.io.FileReader;
  7. import java.io.IOException;
  8. import java.util.ArrayList;
  9. import java.util.List;
  10.  
  11. public class Implementacion {
  12.  
  13.     public static void main(String[] args) {
  14.            String ruta="C:\\Users\\pablo\\Downloads\\133.txt";
  15.            
  16.     }
  17.    
  18.     public static List<String> leer(String nombreArchivo){
  19.               FileReader fr=null;
  20.               File archivo=null;
  21.               List<String>texto=null;
  22.               String linea;
  23.               try{
  24.                   archivo=new File(nombreArchivo);
  25.                   fr=new FileReader(archivo);
  26.                   BufferedReader br=new BufferedReader(fr);
  27.                   texto=new ArrayList<String>();
  28.                   while((linea=br.readLine())!=null){
  29.                         texto.add(linea);
  30.                   }
  31.               }catch(IOException e){
  32.                   System.out.println(e);
  33.               }finally{
  34.                   try{
  35.                       if(fr!=null){
  36.                          fr.close();
  37.                       }
  38.                   }catch(IOException e){
  39.                       System.out.println(e);
  40.                   }
  41.               }
  42.               return texto;
  43.        }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment