Close FileInputStream safely in ZUGFeRDExporterFromPDFA

This commit is contained in:
Malte Neumann
2024-12-03 18:30:10 +01:00
parent 7c9f17218a
commit 4fce6aa8f6

View File

@@ -83,9 +83,10 @@ public class ZUGFeRDExporterFromPDFA implements IZUGFeRDExporter {
} }
protected byte[] filenameToByteArray(String pdfFilename) throws IOException { protected byte[] filenameToByteArray(String pdfFilename) throws IOException {
FileInputStream fileInputStream = new FileInputStream(pdfFilename); try (FileInputStream fileInputStream = new FileInputStream(pdfFilename)) {
return inputstreamToByteArray(fileInputStream); return inputstreamToByteArray(fileInputStream);
} }
}
protected byte[] inputstreamToByteArray(InputStream fileInputStream) throws IOException { protected byte[] inputstreamToByteArray(InputStream fileInputStream) throws IOException {
byte[] bytes = new byte[fileInputStream.available()]; byte[] bytes = new byte[fileInputStream.available()];