Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void BuscarEnArchivo(String nBuscar){
- try{
- File f = new File("Datos.txt");
- if (f.exists()){
- FileReader fr = new FileReader(f);
- BufferedReader br = new BufferedReader(fr);
- String linea;
- boolean encontrado = false;
- while((linea = br.readLine()) !=null){
- String [] arreglo = linea.split("%");
- if (arreglo[0].equalsIgnoreCase(nBuscar)){
- Persona persona = new Persona(arreglo[0], arreglo[1], arreglo[2], arreglo[3], arreglo[4]);
- System.out.println("Persona Encontrada");
- System.out.println(persona.toString());
- encontrado = true;
- }//ifarreglo
- }//while
- br.close();
- fr.close();
- if(!encontrado){
- System.out.println("No hay coincidencias");
- }
- }//if
- }catch(Exception e){
- System.out.println("Error de S/N " + e);
- }//TryCatch
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement