我正在使用 BeanIO.jar 将 bean 文件值写入 CSV 文件。我没有收到任何错误,但内容没有写入 CSV 文件。
请找到我的代码并帮助我
public class CSVStreamWriter {
public void splitandWrite(List<Orders> orderList) {
StreamFactory factory = StreamFactory.newInstance();
factory.load("mapping.xml");
BeanWriter writer = factory.createWriter("orders", new File(
"C:\\sales.csv"));
Orders orders = new Orders();
orders.setCustomerId("1");
orders.setCustomerName("krish");
orders.setPackages("5");
orders.setPackageType("units");
orders.setProductName("oreo");
orders.setQuantity("100");
writer.write(orders);
}
}
我的映射文件
<?xml version="1.0" encoding="UTF-8"?>
<beanio xmlns="http://www.beanio.org/2012/03">
<stream name="orders" format="csv">
<record name="orders" class="com.tedge.mc.Orders">
<field name="customerId" />
<field name="customerName" />
<field name="quantity" />
<field name="productName" />
<field name="packages" />
<field name="packageType" />
</record>
</stream>
</beanio>
最佳答案
关于java - 使用 BeanIO 框架将 bean 值写入 CSV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28629677/