Qualcosa non quadra.... Questa classe dovrebbe prendere controllare l'esistenza di un file, e se esiste aggiungere nel posto corretto nome, cognome e punteggio.....

Non capisco xke non funziona.... ç__ç
Funziona se il file è completo al 100% (ergo: 10 posizioni)
altrimenti va in crisi... XKE????

AIUTOOO!!!
HighScores.java
codice:
import java.awt.Desktop;
import java.io.*;


public class HighScores {
    
    private File puntiFile;
    private String testoHTML, buffLine, doc;
    private String[] rigaIn, rigaOut = new String[4];
    private BufferedReader buffReader;
    private FileOutputStream outFile;

    /**
     * Crea l'oggetto.
     */
    public HighScores(){        
    }
    
    /**
     * Aggiunge *se necessario* il punteggio fornito nella posizione corretta.
     * @param name nome dell'utente
     * @param surname cognome dell'utente
     * @param point punteggio de''utente
     */
    public void addPoint(String name, String surname, Integer point){
  
        int i = 1;
        int punti = point;
        doc = "";
        rigaOut[0] = name;
        rigaOut[1] = surname;
        rigaOut[2] = point.toString();
        boolean scritto = false;
        boolean flag =false;
        
        
        puntiFile = new File("./punteggi.dat");
        
        try{
            if(!puntiFile.exists())
            {
            puntiFile.createNewFile();
            doc += rigaOut[0]+"|"+rigaOut[1]+"|"+rigaOut[2]+"\n";
            System.out.println("* Nuovo");
            }
        else{
            try{
            
            buffReader = new BufferedReader(new FileReader(puntiFile));
            while(buffReader.ready() && i<=10)
            {
                buffLine = buffReader.readLine();
                rigaIn = buffLine.split("\\|");
                Integer puntiRead = Integer.parseInt(rigaIn[2]);
                if(rigaOut[0].equals(rigaIn[0]) && rigaOut[1].equals(rigaIn[1]) && rigaOut[2].equals(rigaIn[2]))
                    {
                        flag = true;
                        System.out.println("___Flag Found!!!!");
                    }

                if (puntiRead > punti || scritto || flag)
                    {
                    
                    doc += rigaIn[0]+"|"+rigaIn[1]+"|"+rigaIn[2]+"\n";
                    System.out.println(i+"*NON* Scritto Nuovo");
                    i++;
                }
                else if (puntiRead <= punti && !flag) {
                   if (!scritto){
                        doc += rigaOut[0]+"|"+rigaOut[1]+"|"+rigaOut[2]+"\n";
                        System.out.println(i+"*Scritto Nuovo");
                        i++;
                        scritto = true;
                       
                        }
                   if (scritto)
                    {
                            i++;
                            System.out.println(i+" -----Aggionamento Lista");
                            doc +=rigaIn[0]+"|"+rigaIn[1]+"|"+rigaIn[2]+"\n";
                    }
                        
                }
                
            }
            
        }catch (Exception exxe){
            System.out.println("Errore file: "+ exxe);
        }
        }
            
            outFile = new FileOutputStream(puntiFile);
            PrintStream output = new PrintStream(outFile);
            output.println(doc);
            output.flush();
            System.out.println(i+"-------- Scritto tutto");
            output.close();
            
        } catch (Exception exe){
            System.out.println("Errore exe: "+ exe);
        }
    }
    
    
    /**
     * Fa creare la pagina e mostra la tabella in un Browser.
     */
    public void showTable(){
        makeHtml();
        try {
            Desktop desktop = null;
            if (Desktop.isDesktopSupported()) {
                desktop = Desktop.getDesktop();
            }
            desktop.open(new File("outputJava.html"));
        } catch (IOException ioe) {
            System.out.println("Errore ioe: "+ioe);
            ioe.printStackTrace();
        }
    }
    
    /**
     * Crea la tabella in HTML con i dati del file "punteggi.dat"
     */
    private void makeHtml(){
        
        testoHTML =
                    "<head>" +
                    "\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />" +
                    "\n <title>Air Combat HighScores!</title>" +
                    "\n </head>" +
                    "\n  <body>" +
                    "\n\n   <table width=\"100%\" border=\"1\">" +
                    "\n    <tr bgcolor=\"#0033FF\" style=\"font-style:oblique\">" +
                    "\n       <td width=\"4%\" height=\"28\"><div align=\"center\">Pos.</div></td>" +
                    "\n       <td width=\"24%\"><div align=\"center\">Nome</div></td>" +
                    "\n       <td width=\"35%\"><div align=\"center\">Cognome</div></td>" +
                    "\n       <td width=\"37%\"><div align=\"center\">Valutazione</div></td>" +
                    "\n    </tr>";
        
        try{
            puntiFile = new File("./punteggi.dat");
            buffReader = new BufferedReader(new FileReader(puntiFile));
            
            for(int row = 1; row<=10; row++){

                buffLine = buffReader.readLine();
                String[] toPrint = buffLine.split("\\|");
                String color =null;
                if (row % 2 == 0)
                    color = "0099FF";
                else if (row % 2 != 0)
                    color="00FFFF";
                testoHTML +=
                        "\n	   <tr bgcolor=\"#"+color+"\">" +
                        "\n          <td><div align=\"center\">"+row+"</div></td>" +
                        "\n          <td>"+toPrint[0]+"</td>" +
                        "\n          <td>"+toPrint[1]+"</td>" +
                        "\n          <td>"+toPrint[2]+"</td>" +
                        "\n        </tr>";
            }
            
            testoHTML += "\n </table>\n  </body>\n</html>";
            
            outFile = new FileOutputStream("outputJava.html");
            PrintStream output = new PrintStream(outFile);
            output.println(testoHTML);
            output.flush();
//            System.out.println("****Scritto File****");
            output.close();
            
        } catch (Exception ex) {
            System.out.println("Errore ex: "+ ex);
        }

    }  

    public static void main(String[]args){
        
        HighScores  hi = new HighScores();
        hi.addPoint("Pipp", "Oppip", 292);
        hi.addPoint("Pipp", "Oppip", 252);
        hi.addPoint("MA", "SA", 1000);
        hi.addPoint("MA", "Ve", 500);
        hi.addPoint("RE", "MA", 100);
        hi.addPoint("XD", "pm", 120);
        hi.addPoint("ert", "pol", 40);
        //hi.showTable();
    }

}
Qio sotto come deve essere strtturato il file punteggi.dat!
codice:
qwe|ert|1000
rty|sdf|550
PIO|lkj|510
//...
//String nome | String congome | Int punti
Aiutatemi!!1