Merge pull request #600 from Malte-Neu/fixResourceHandle

Fixes a problem where a stream was not safely closed
This commit is contained in:
Jochen Staerk
2024-12-19 16:16:56 +01:00
committed by GitHub

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()];