Tighten up file closing on exceptions
This commit is contained in:
parent
5c064eab2b
commit
d70ea37b31
3 changed files with 59 additions and 10 deletions
|
|
@ -157,14 +157,21 @@ public class RegionsComponent extends ClientComponent {
|
|||
else {
|
||||
outputFile = new File(plugin.getDataFolder(), webWorldPath.toString());
|
||||
}
|
||||
FileOutputStream fos = null;
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream(outputFile);
|
||||
fos = new FileOutputStream(outputFile);
|
||||
fos.write(Json.stringifyJson(regionData).getBytes());
|
||||
fos.close();
|
||||
} catch (FileNotFoundException ex) {
|
||||
Log.severe("Exception while writing JSON-file.", ex);
|
||||
} catch (IOException ioe) {
|
||||
Log.severe("Exception while writing JSON-file.", ioe);
|
||||
} finally {
|
||||
if(fos != null) {
|
||||
try {
|
||||
fos.close();
|
||||
} catch (IOException iox) {}
|
||||
fos = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue