|
|
@@ -249,9 +249,8 @@ public class PdfController {
|
|
|
if(!file.getName().toLowerCase().endsWith(".pdf")){
|
|
|
throw new IOException("并非 pdf 文件:" + p);
|
|
|
}
|
|
|
- FileInputStream fis = new FileInputStream(file);
|
|
|
|
|
|
- try {
|
|
|
+ try (FileInputStream fis = new FileInputStream(file)) {
|
|
|
response.setHeader("Content-Length", file.length() + "");
|
|
|
response.setContentType("application/pdf");
|
|
|
|
|
|
@@ -266,8 +265,6 @@ public class PdfController {
|
|
|
} catch (IOException e) {
|
|
|
logger.error(e.getMessage());
|
|
|
}
|
|
|
- } finally {
|
|
|
- fis.close();
|
|
|
}
|
|
|
}
|
|
|
}
|