Issue #3628 - Closed unclosed input stream
This commit is contained in:
parent
d4522c7c16
commit
c67eca5faa
|
@ -25,14 +25,20 @@ public class MultipartController {
|
||||||
try {
|
try {
|
||||||
InputStream in = file.getInputStream();
|
InputStream in = file.getInputStream();
|
||||||
String path = new File(".").getAbsolutePath();
|
String path = new File(".").getAbsolutePath();
|
||||||
FileOutputStream f = new FileOutputStream(path.substring(0, path.length()-1)+ "/uploads/" + file.getOriginalFilename());
|
FileOutputStream f = new FileOutputStream(path.substring(0, path.length() - 1) + "/uploads/" + file.getOriginalFilename());
|
||||||
int ch;
|
try {
|
||||||
while ((ch = in.read()) != -1) {
|
int ch;
|
||||||
f.write(ch);
|
while ((ch = in.read()) != -1) {
|
||||||
|
f.write(ch);
|
||||||
|
}
|
||||||
|
modelAndView.getModel().put("message", "File uploaded successfully!");
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("Exception uploading multipart: " + e);
|
||||||
|
} finally {
|
||||||
|
f.flush();
|
||||||
|
f.close();
|
||||||
|
in.close();
|
||||||
}
|
}
|
||||||
f.flush();
|
|
||||||
f.close();
|
|
||||||
modelAndView.getModel().put("message", "File uploaded successfully!");
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("Exception uploading multipart: " + e);
|
System.out.println("Exception uploading multipart: " + e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue