Salve.
Ho questo codice che deve leggere delle righe da un file:

codice:
File studente = new File(unico[i]+".txt");

    stud = new BufferedReader( new InputStreamReader(new FileInputStream(studente)));
    nume=0;
    while ((stud.readLine()!=null) || (stud.readLine()==""))
  nume++;
    stud = new BufferedReader( new InputStreamReader(new FileInputStream(studente)));
    
    for (j=0; j<nume; j++){
    esami[j]=stud.readLine();
    System.out.println(j);

    
    String[] esame = esami[j].split("\\,");
    
    String voto = esame[2];
    String vo = voto.substring(1,voto.length());
    
    vot=Integer.parseInt(vo);
    
    
    
    System.out.println("voto"+vot);
    temp.esameSuperato(vot);
    
    numEsami = temp.getNumeroEsamiSuperati();
    media = temp.getMedia();
    temp.stampaStudente(unPS); 
}
Il problema è che se uno di quei file in cui vado a leggere ha delle righe vuote alla fine, mi restituisce questo errore:
codice:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
	at homework1.Testudente.main(Testudente.java:84)
Come devo fare?