Hi there,
BeanIO reference guide states that for a fixed-length stream:
if required is set to false, spaces are unmarshalled to a null field value regardless of the padding character.
@Record
public class Pojo {
@Field(length = 5, required = false)
String field;
// constructor, getters, setters
}
@Test
public void test(){
StreamFactory factory = StreamFactory.newInstance();
factory.define(new StreamBuilder("pojo")
.format("fixedlength")
.addRecord(Pojo.class));
Unmarshaller unmarshaller = factory.createUnmarshaller("pojo");
Pojo pojo = (Pojo) unmarshaller.unmarshal(" "); // 5 spaces
assertNull(pojo.field);
}
Well, you can always try trim="true" lazy="true".
--
You received this message because you are subscribed to the Google Groups "beanio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beanio+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.