我正在使用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>
答案 0 :(得分:2)