From 8e463ca7da5cc258beebbc79b43d4bc2d1e8ee44 Mon Sep 17 00:00:00 2001 From: Score_Under Date: Sat, 2 Aug 2014 16:47:08 +0100 Subject: [PATCH] Use the File constructor rather than File.separator; use file.getName() rather than its toString(); close "fout" even if "in" could not be --- src/main/java/net/gravitydevelopment/updater/Updater.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/gravitydevelopment/updater/Updater.java b/src/main/java/net/gravitydevelopment/updater/Updater.java index 350cc66..b1556ad 100644 --- a/src/main/java/net/gravitydevelopment/updater/Updater.java +++ b/src/main/java/net/gravitydevelopment/updater/Updater.java @@ -337,7 +337,7 @@ private void saveFile(File folder, String file, String link) { downloadFile(link, folder); // Check to see if it's a zip file, if it is, unzip it. - final File dFile = new File(folder.getAbsolutePath() + File.separator + file); + final File dFile = new File(folder.getAbsolutePath(), file); if (dFile.getName().endsWith(".zip")) { // Unzip this.unzip(dFile.getAbsolutePath()); @@ -359,7 +359,7 @@ private void downloadFile(String link, File folder) { URL fileUrl = new URL(link); final int fileLength = fileUrl.openConnection().getContentLength(); in = new BufferedInputStream(fileUrl.openStream()); - fout = new FileOutputStream(folder.getAbsolutePath() + File.separator + file); + fout = new FileOutputStream(new File(folder, file.getName())); final byte[] data = new byte[Updater.BYTE_SIZE]; int count; @@ -383,6 +383,10 @@ private void downloadFile(String link, File folder) { if (in != null) { in.close(); } + } catch (final IOException ex) { + plugin.getLogger().log(Level.SEVERE, null, ex); + } + try { if (fout != null) { fout.close(); }