简体   繁体   中英

Java to CSV with Smooks

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", .............

Thanks!

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

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

update Working example can be found here at github

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM