Prova così:
codice:BufferedReader br = null; try { br = new BufferedReader(new FileReader(file)); } catch (FileNotFoundException e) { e.printStackTrace(); } boolean trovato=false; String riga=null; String codice="1";//codice da cercare try { riga = br.readLine(); } catch (IOException ex) { ex.printStackTrace(); } while(riga!=null){ if(riga.startsWith(codice)){ //controllo System.out.println("Risultato="+riga); trovato=true; } try { riga = br.readLine(); } catch (IOException ex) { ex.printStackTrace(); } } if(!trovato) System.out.println("Nessun riscontro");![]()

Rispondi quotando