0
固定長ファイルを変換しようとしていますが、複数のファイルで失敗し、1行で動作します。Apache Camel複数行ファイルの解析に失敗しました
public class SampleCamelRouter extends RouteBuilder {
Processor processor = new FixedMapProcessor();
DataFormat bindy = new BindyFixedLengthDataFormat(Order.class);
@Override
public void configure() throws Exception {
from("file:C:/Users/in").unmarshal(bindy)
.split(body()).process(new Processor() {
public void process(Exchange exchange) throws Exception {
//Below is not working
List<Map<String, Object>> unmarshaledModels = (List<Map<String, Object>>) exchange.getIn().getBody();
//Below is working
Order2 unmarshaledModels = (Order2) exchange.getIn().getBody();
}
}).end();
}
}
注文:
@FixedLengthRecord(length = 4, paddingChar = ' ')
public class Order1 {
@DataField(pos = 1, length = 2)
private int orderNr;
@DataField(pos = 3, length = 2)
private String clientNr;
}
C:/Users/in/test.txt
10AB
20CD
例外:
java.lang.ClassCastException: com.camel.fixed1.Order cannot be cast to java.util.List