如何使用输出文件的 Java DSL 更改 csv 分隔符?
from("timer://foo?fixedRate=true&delay=0&period=2000").
to("http://graph.facebook.com/nike").unmarshal().json(JsonLibrary.Gson,Map.class)
.marshal().csv().to("file:target/output");
最佳答案
你能试试这个吗:
CsvDataFormat csv = new CsvDataFormat();
CSVConfig config = new CSVConfig();
config.setDelimiter('|'); // your delimiter here
csv.setConfig(config);
from("timer://foo?fixedRate=true&delay=0&period=2000").
to("http://graph.facebook.com/nike").unmarshal().json(JsonLibrary.Gson,Map.class)
.marshal(csv).convertBodyTo(String.class).to("file:target/output");
不确定 ConvertBodyTo(String.class) 是否必要
关于java - 使用 Java DSL 更改 CSV 输出分隔符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20267426/