能否请您提出在从Bean创建CSV时如何删除双引号的建议。
请在代码下方找到。
这可以很好地使用双引号。请提出建议。
public String creatrCSVFromBean(DeviceDetails deviceDetails) {
try {
System.out.println("csvLocation--"+csvLocation);
FileWriter writer = new FileWriter("D:\\csvfile.csv");
List<DeviceDetails> deviceDetailsList = new ArrayList<DeviceDetails>();
DeviceDetails deviceDetailsObj=new DeviceDetails(
deviceDetails.getBarcode().toUpperCase(),deviceDetails.getDateofmanufacture().toUpperCase(),deviceDetails.getSerialnumber().toUpperCase(),deviceDetails.getComments().toUpperCase(),
deviceDetails.getTypenumber().toUpperCase(),
deviceDetails.getManufacturername().toUpperCase(),deviceDetails.getStatus().toUpperCase(),
deviceDetails.getNename().toUpperCase(),
deviceDetails.getParentbarcode().toUpperCase(),
deviceDetails.getSlotposition().toUpperCase(),deviceDetails.getUpdateflag().toUpperCase());
deviceDetailsList.add(deviceDetailsObj);
System.out.println(deviceDetailsObj);
System.out.println(deviceDetailsList);
// Create Mapping Strategy to arrange the
// column name in order
ColumnPositionMappingStrategy mappingStrategy= new ColumnPositionMappingStrategy();
mappingStrategy.setType(DeviceDetails.class);
String[] columns = new String[] {"barcode","dateofmanufacture","serialnumber","comments","typenumber",
"manufacturername","status","nename","parentbarcode",
"slotposition","updateflag"};
mappingStrategy.setColumnMapping(columns);
// Createing StatefulBeanToCsv object
StatefulBeanToCsvBuilder<DeviceDetails> builder= new StatefulBeanToCsvBuilder(writer);
StatefulBeanToCsv beanWriter = builder.withMappingStrategy(mappingStrategy).build();
// Write list to StatefulBeanToCsv object
beanWriter.write(deviceDetailsList);
// closing the writer object
writer.close();
}catch (Exception e) {
e.printStackTrace();
}
return "CSV created ok";
}