BufferedWriter is acting strange

后端 未结 3 1775
小蘑菇
小蘑菇 2021-01-16 14:02

I am trying to make a game with a working highscore mechanism and I am using java.io.BufferedWriter to write to a highscore file. I don\'t have an encryption on the highscor

3条回答
  •  执念已碎
    2021-01-16 15:00

    BufferedWriter.write(int) is meant to write a single charecter, not a integer.

    public void write(int c)
    throws IOException

    Writes a single character.

    Overrides: write in class Writer
    Parameters: c - int specifying a character to be written
    Throws: IOException - If an I/O error occurs

    Try

    writer.write(String.valueOf(score));  
    

提交回复
热议问题