The issue is with your these lines of code in main
method
try
{
savePlayers();
}
catch (IOException ex) {
ex.printStackTrace();
}
Change it to catch
try
{
savePlayers();
}
catch (Exception ex) {
ex.printStackTrace();
}
It will work. Your savePlayers()
method throws Exception
not IOException
.
The above will fix the issue but I don't know why your savePlayers() method have this strange throws Exception
in method definition? You should think to remove it, as your code not throwing any exception. If it is, handle it along with your IOException
.