Reputation: 6717
How can I remove leading/trailing white space before/while marshalling in JAXB?
Upvotes: 4
Views: 4251
Reputation: 403581
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 ' '.
Upvotes: 8