Java到smooks的CSV文件 [英] Java to CSV with Smooks

查看:134
本文介绍了Java到smooks的CSV文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Smooks是否可以基于Java实例生成CSV文件?

Is there a way Smooks could generate a CSV file based on a java instance?

我正在寻找类似的东西:

I am looking for something like:

public static void main(String[] args){
  Employee emp = new Employee();
  emp.setName("abc");
  emp.setSalary(12312);
  /* set other emp fields */

  smooks.filterSource(.....);
}

CSV Output: "abc","12312", .............

谢谢!

推荐答案

只需看看Smooks文档

Just take a look at Smooks documentation here, it is done by wrapping your bean with JavaSource object - example can be found here

然后,您可以使用FreeMarker模板将Java Object转换为所需的格式-

Then you can use FreeMarker template to transform Java Object into desired format - look here

更新 可以在在github上找到工作示例

这篇关于Java到smooks的CSV文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆