From 29d09922b9d2c625180c2d55730feb16a6ca5321 Mon Sep 17 00:00:00 2001 From: Tastybento Date: Wed, 7 Feb 2018 19:33:59 -0800 Subject: [PATCH] Switched to use Files.delete When File.delete fails, this boolean method simply returns false with no indication of the cause. On the other hand, when Files.delete fails, this void method returns one of a series of exception types to better indicate the cause of the failure. More information is generally better in a debugging situation, so I'll use this option. --- .../database/flatfile/FlatFileDatabaseHandler.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/us/tastybento/bskyblock/database/flatfile/FlatFileDatabaseHandler.java b/src/main/java/us/tastybento/bskyblock/database/flatfile/FlatFileDatabaseHandler.java index ce547914b..04552239a 100644 --- a/src/main/java/us/tastybento/bskyblock/database/flatfile/FlatFileDatabaseHandler.java +++ b/src/main/java/us/tastybento/bskyblock/database/flatfile/FlatFileDatabaseHandler.java @@ -4,10 +4,12 @@ import java.beans.IntrospectionException; import java.beans.PropertyDescriptor; import java.io.File; import java.io.FilenameFilter; +import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Type; +import java.nio.file.Files; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -520,9 +522,12 @@ public class FlatFileDatabaseHandler extends AbstractDatabaseHandler { File dataFolder = new File(plugin.getDataFolder(), DATABASE_FOLDER_NAME); File tableFolder = new File(dataFolder, dataObject.getSimpleName()); if (tableFolder.exists()) { + File file = new File(tableFolder, fileName); - if (!file.delete()) { - plugin.getLogger().severe("Could not delete yaml database object! " + file.getName()); + try { + Files.delete(file.toPath()); + } catch (IOException e) { + plugin.getLogger().severe("Could not delete yaml database object! " + file.getName() + " - " + e.getMessage()); } } }