From 2cb99ed04df209e0fc72ac217c103efe753804e3 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 4 Sep 2018 12:29:50 -0700 Subject: [PATCH] Use existing utility method. This also avoids the weird old structure that closed an auto-closed input stream inside the try-with-resources block. --- .../com/threerings/getdown/util/FileUtil.java | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/com/threerings/getdown/util/FileUtil.java b/core/src/main/java/com/threerings/getdown/util/FileUtil.java index 3b1ac18..3fd48ee 100644 --- a/core/src/main/java/com/threerings/getdown/util/FileUtil.java +++ b/core/src/main/java/com/threerings/getdown/util/FileUtil.java @@ -50,23 +50,17 @@ public class FileUtil } // as a last resort, try copying the old data over the new - try (FileInputStream fin = new FileInputStream(source); - FileOutputStream fout = new FileOutputStream(dest)) { - - StreamUtil.copy(fin, fout); - - // close the input stream now so we can delete 'source' - fin.close(); - if (!deleteHarder(source)) { - log.warning("Failed to delete " + source + - " after brute force copy to " + dest + "."); - } - return true; - + try { + copy(source, dest); } catch (IOException ioe) { log.warning("Failed to copy " + source + " to " + dest + ": " + ioe); return false; } + + if (!deleteHarder(source)) { + log.warning("Failed to delete " + source + " after brute force copy to " + dest + "."); + } + return true; } /**