Hi everyone,
I am trying to create a csv file.
One field that I am trying to out put is the description and has commas, that is throwing my columns out of sync.
I have tries putting the charactor ' around the data but all it does is output that charactor in the data.
my code is this
public File createFile(Vector downloadObject){
Iterator iterator = downloadObject.iterator();
String query ="";
try {
Format formatter2 = new SimpleDateFormat("ddMMyyyy");
String fileName="DELIVERY" + ".csv";
File file = new File(fileName);
StringBuffer output = new StringBuffer();
while (iterator.hasNext()){
VODownloadObject downloadObject2 = (VODownloadObject)iterator.next();
query =
"'" +
downloadObject2.getStrokeNumber().trim()
+ "','"+ downloadObject2.getJdeIdNumber()
+ "','"+ downloadObject2.getRollNumber()
+ "','"+ downloadObject2.getSupplier()
+ "',"+ ",'"+ downloadObject2.getQuality()
+ "','"+ downloadObject2.getColour()
+ "','"+ downloadObject2.getSupplierRollNumber()
+ "',"+ ",'"+ downloadObject2.getDeliveryDate()
+ "','"+ downloadObject2.getFabricComposition()
+ "',"+ ","+ ",'"+ downloadObject2.getTicketLength()
+ "','"+ downloadObject2.getTicketWidth()
+ "',"+ ","+ ","+ ",";
output.append(query + "\r\n");
}
BufferedWriter out = new BufferedWriter(new FileWriter(fileName));
out.write(output.toString());
out.close();
return file;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
the output is this.
'PA?????T','2/664659 ','153920','Menswear Formal, Shirts ',,'null','null',' ',,'11/07/2006','null',,,'-330000',' ',
in the "'Menswear Formal, Shirts " field, this is one field but it is splitting up into 2 fields because there is a comma after Formal. Anyone know how I can keep this as one field but with a comma in it?
thanks in advance