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?
In the current code it seems the Ini class works on the file and does not give you any access to the stream.
So either