我正在尝试编写一个简单的函数,将我的播放器的配置文件保存到内部文件,但它会在outputWriter初始化时抛出NullPointerException。
public void saveProfile(String filePath){
BufferedWriter outputWriter;
try{
outputWriter = new BufferedWriter(new OutputStreamWriter(Gdx.files.local(filePath).write(false)));
saveInfo[pid]=count;
gamesLost=saveInfo[pgamesLost]=gamesLost;
gamesWon=saveInfo[pgamesWon]=gamesWon;
saveName=name;
outputWriter.write(name+"\n");
for(int i=0;i<saveInfo.length;i++){
outputWriter.write(Integer.toString(saveInfo[i])+"\n");
}
outputWriter.close();
}catch (Exception e) {
e.printStackTrace();
}
}