How can I remove leading/trailing white space before/while marshalling in JAXB?
You could use CollapsedStringAdapter
:
public class MyClass {
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
private String field;
}
This adapter removes leading and trailing whitespaces, then truncate any sequnce of tab, CR, LF, and SP by a single whitespace character ' '.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With