Skip to content

Commit

Permalink
Use the File constructor rather than File.separator; use file.getName…
Browse files Browse the repository at this point in the history
…() rather than its toString(); close "fout" even if "in" could not be
  • Loading branch information
ScoreUnder committed Aug 2, 2014
1 parent 65254e1 commit 8e463ca
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/net/gravitydevelopment/updater/Updater.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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;
Expand All @@ -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();
}
Expand Down

0 comments on commit 8e463ca

Please sign in to comment.