Java 8 compatibility

This commit is contained in:
Dominik Röschke
2024-05-02 14:49:09 +02:00
parent adbb7c1840
commit 37fb01c8fd
2 changed files with 4 additions and 2 deletions

View File

@@ -15,6 +15,7 @@ import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.io.IOUtils;
import org.dom4j.DocumentException; import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper; import org.dom4j.DocumentHelper;
import org.dom4j.io.OutputFormat; import org.dom4j.io.OutputFormat;
@@ -245,7 +246,7 @@ public class ZUGFeRDValidator {
context.addResultItem( context.addResultItem(
new ValidationResultItem(ESeverity.fatal, "File too small").setSection(5).setPart(EPart.pdf)); new ValidationResultItem(ESeverity.fatal, "File too small").setSection(5).setPart(EPart.pdf));
} else { } else {
content = inputStream.readAllBytes(); content = IOUtils.toByteArray(inputStream);
isPDF = ByteArraySearcher.contains(content, new byte[]{'%', 'P', 'D', 'F'}); isPDF = ByteArraySearcher.contains(content, new byte[]{'%', 'P', 'D', 'F'});
XMLValidator xv = new XMLValidator(context); XMLValidator xv = new XMLValidator(context);
if (isPDF) { if (isPDF) {

View File

@@ -5,6 +5,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -43,7 +44,7 @@ public class ResourceCase extends TestCase {
if (in == null) { if (in == null) {
return null; return null;
} }
return in.readAllBytes(); return IOUtils.toByteArray(in);
} catch (IOException e) { } catch (IOException e) {
LOGGER.error(e.getMessage(), e); LOGGER.error(e.getMessage(), e);
return null; return null;