Skip to content

Commit

Permalink
Merge pull request LianjiaTech#84 from khaes-kth/fix/Sonar_2095
Browse files Browse the repository at this point in the history
Fix violations of Sonar rule 2095
  • Loading branch information
chentianming11 authored Dec 8, 2021
2 parents 409cd23 + 50900c1 commit c6cbb63
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ public void download() throws Exception {
if (!file.exists()) {
file.createNewFile();
}
FileOutputStream fos = new FileOutputStream(file);
byte[] b = new byte[1024];
int length;
while ((length = is.read(b)) > 0) {
fos.write(b, 0, length);
try (FileOutputStream fos = new FileOutputStream(file)) {
byte[] b = new byte[1024];
int length;
while ((length = is.read(b)) > 0) {
fos.write(b, 0, length);
}
is.close();
fos.close();
}
is.close();
fos.close();
}
}

0 comments on commit c6cbb63

Please sign in to comment.