whitespace corrections+switch to ioutils
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
- Fix #389: ClassCastException: ZUGFeRDExporterFromA3
|
- Fix #389: ClassCastException: ZUGFeRDExporterFromA3
|
||||||
- jakarta support #372
|
- jakarta support #372
|
||||||
- Upgrade to PDFBox 3 #373
|
- Upgrade to PDFBox 3 #373
|
||||||
|
- Requires Java 11
|
||||||
- #397
|
- #397
|
||||||
- #392 CLI: action combine: --ignorefileextension to ignore PDF/A input file errors dosen't work
|
- #392 CLI: action combine: --ignorefileextension to ignore PDF/A input file errors dosen't work
|
||||||
- for CLI combine, fx is now default
|
- for CLI combine, fx is now default
|
||||||
|
|||||||
@@ -14,10 +14,7 @@ package org.mustangproject.ZUGFeRD;
|
|||||||
* @author jstaerk
|
* @author jstaerk
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.*;
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@@ -43,8 +40,8 @@ import javax.xml.xpath.XPathExpression;
|
|||||||
import javax.xml.xpath.XPathExpressionException;
|
import javax.xml.xpath.XPathExpressionException;
|
||||||
import javax.xml.xpath.XPathFactory;
|
import javax.xml.xpath.XPathFactory;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.pdfbox.Loader;
|
import org.apache.pdfbox.Loader;
|
||||||
import org.apache.pdfbox.io.IOUtils;
|
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||||
import org.apache.pdfbox.pdmodel.PDDocumentNameDictionary;
|
import org.apache.pdfbox.pdmodel.PDDocumentNameDictionary;
|
||||||
import org.apache.pdfbox.pdmodel.PDEmbeddedFilesNameTreeNode;
|
import org.apache.pdfbox.pdmodel.PDEmbeddedFilesNameTreeNode;
|
||||||
@@ -786,11 +783,11 @@ public class ZUGFeRDImporter {
|
|||||||
|
|
||||||
|
|
||||||
static String convertStreamToString(java.io.InputStream is) {
|
static String convertStreamToString(java.io.InputStream is) {
|
||||||
// TODO wouldn't we use IOUtils.toByteArray nowadays???
|
try {
|
||||||
// source https://stackoverflow.com/questions/309424/how-do-i-read-convert-an-inputstream-into-a-string-in-java referring to
|
return IOUtils.toString(is, StandardCharsets.UTF_8);
|
||||||
// https://community.oracle.com/blogs/pat/2004/10/23/stupid-scanner-tricks
|
} catch (IOException e) {
|
||||||
final Scanner s = new Scanner(is, StandardCharsets.UTF_8).useDelimiter("\\A");
|
throw new UncheckedIOException(e);
|
||||||
return s.hasNext() ? s.next() : "";
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ public class ZUGFeRDValidator {
|
|||||||
try {
|
try {
|
||||||
xv.validate();
|
xv.validate();
|
||||||
} catch (IrrecoverableValidationError irx) {
|
} catch (IrrecoverableValidationError irx) {
|
||||||
LOGGER.info("The hell");
|
LOGGER.error("XML validation threw an exception ", irx);
|
||||||
}
|
}
|
||||||
finalStringResult.append(xv.getXMLResult());
|
finalStringResult.append(xv.getXMLResult());
|
||||||
finalStringResult.append("</xml>");
|
finalStringResult.append("</xml>");
|
||||||
@@ -246,8 +246,7 @@ public class ZUGFeRDValidator {
|
|||||||
long inputLength;
|
long inputLength;
|
||||||
try {
|
try {
|
||||||
inputLength = inputStream == null ? 0 : inputStream.available();
|
inputLength = inputStream == null ? 0 : inputStream.available();
|
||||||
}
|
} catch (IOException ex) {
|
||||||
catch (IOException ex) {
|
|
||||||
throw new UncheckedIOException(ex);
|
throw new UncheckedIOException(ex);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -260,8 +259,7 @@ public class ZUGFeRDValidator {
|
|||||||
public String validate(byte[] bytes, String fileNameOfInputStream) {
|
public String validate(byte[] bytes, String fileNameOfInputStream) {
|
||||||
try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes)) {
|
try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes)) {
|
||||||
return internalValidate(fileNameOfInputStream, bais, bytes.length);
|
return internalValidate(fileNameOfInputStream, bais, bytes.length);
|
||||||
}
|
} catch (IOException ex) {
|
||||||
catch (IOException ex) {
|
|
||||||
throw new UncheckedIOException(ex);
|
throw new UncheckedIOException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user