Codigo java
Enviado por Uriel Pelcastre • 16 de Septiembre de 2018 • Examen • 394 Palabras (2 Páginas) • 141 Visitas
import java.io.*;
public class Archivo {
public String leerTxt(String direccion){ //direccion del archivo
String texto = "";
try{
BufferedReader bf = new BufferedReader(new FileReader(direccion));
String temp = "";
String bfRead;
while((bfRead = bf.readLine()) != null){
//haz el ciclo, mientras bfRead tiene datos
temp = (temp+"\r\n"+ bfRead); //guardado el texto del archivo
}
texto = temp;
}catch(Exception e){
System.err.println("No se encontro archivo");
}
return texto;
}
}
.........................................................................................
public class Prinsipal {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Archivo a = new Archivo();
String s1 = a.leerTxt("C:\\ESD\\TXT\\practica.txt");// direccion donde lo guardaste
System.out.println(s1);
}
}
...