public void Checkscore() {

        hscore=getHighScore();
        if (score > Integer.parseInt(hscore.split(":")[1])) {
            String name = JOptionPane.showInputDialog("You set a new highscore.Please enter your name:");

            if (name.equals(null)) {
                name = "Annonimous";
            }
            hscore=name + ":" +score;
            File scoreFile=new File("C:\\highscore.dat");
            if(!scoreFile.exists())
                try {
                    scoreFile.createNewFile();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            FileWriter writeFile=null;
            BufferedWriter writer=null;
            try {
                writeFile=new FileWriter(scoreFile);
                writer=new BufferedWriter(writeFile);
                writer.write(hscore);

            }
            catch (Exception e)
            {

            }

            finally {
                try {
                    if (writer != null)
                        writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

        }
    }