updated history. got rid of one more readallbytes

This commit is contained in:
jstaerk
2023-11-26 18:46:33 +01:00
parent 656fec6359
commit 771fbbab2c
2 changed files with 15 additions and 10 deletions

View File

@@ -60,8 +60,12 @@ public class ZUGFeRDExporterFromPDFA implements IZUGFeRDExporter {
return theExporter;
}
private byte[] fileToByteArrayInputStream(String pdfFilename) throws IOException {
protected byte[] filenameToByteArray(String pdfFilename) throws IOException {
FileInputStream fileInputStream = new FileInputStream(pdfFilename);
return inputstreamToByteArray(fileInputStream);
}
protected byte[] inputstreamToByteArray(InputStream fileInputStream) throws IOException {
byte[] bytes = new byte[fileInputStream.available()];
DataInputStream dataInputStream = new DataInputStream(fileInputStream);
dataInputStream.readFully(bytes);
@@ -105,7 +109,7 @@ public class ZUGFeRDExporterFromPDFA implements IZUGFeRDExporter {
* @throws IOException
*/
public IZUGFeRDExporter load(String pdfFilename) throws IOException {
determineAndSetExporter(getPDFAVersion(fileToByteArrayInputStream(pdfFilename)));
determineAndSetExporter(getPDFAVersion(filenameToByteArray(pdfFilename)));
return theExporter.load(pdfFilename);
}
@@ -133,7 +137,7 @@ public class ZUGFeRDExporterFromPDFA implements IZUGFeRDExporter {
* @throws IOException if anything is wrong with inputstream
*/
public IZUGFeRDExporter load(InputStream pdfSource) throws IOException {
determineAndSetExporter(getPDFAVersion(pdfSource.readAllBytes()));
determineAndSetExporter(getPDFAVersion(inputstreamToByteArray(pdfSource)));
return theExporter.load(pdfSource);
}