I have the following code below which uses the ini4j library to load a file as a .ini file.
Ini configIni;
public void setupConfig()
{
String configFilePath = "config.ini";
File config = new File(configFilePath);
if(config.exists())
{
try
{
configIni = new Ini(config);
}
catch(Exception e)
{
config.delete();
config.deleteOnExit();
e.printStackTrace();
}
}
}
In the event that it fails to parse correctly it will throw an exception. Problem is, I want to get rid of the config file when this happens in order to replace with it a default one. But for some reason the application holds onto the file even though configIni
is null.
I don't know how to tell ini4j or Java to let go/close the stream of the config file so I can delete it.
Any ideas how I can do this?
question from:
https://stackoverflow.com/questions/65848101/ini4j-how-to-close-the-file-stream-after-parsing-error 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…