String newPurchaseOrder = dateStr + "#" + customerID + "#" + productCode + "#" + qty;
try {
String filename = "PurchaseOrderDataFile.txt";
FileWriter fw = new FileWriter(filename, true); //the true will append the new data
BufferedWriter bw = new BufferedWriter(fw);
FileReader fr = new FileReader("PurchaseOrderDataFile.txt");
bw.write("\n" + newPurchaseOrder);
bw.close();
} catch (IOException ioe) {
System.err.println("IOException: " + ioe.getMessage());
}
尝试防止它在输入到 .txt 文件时跳行
08/12/13#PMI-1256#DT/9489#8
16/12/13#ENE-5789#PV/5732#25
27/12/13#PEA-4567#PV/5732#3@
09/01/14#PEA-4567#DT/9489#1
16/01/14#EMI-6329#PV/5732#8
16/07/13#ESE-5577#ZR/7413#6
输入跳过如上的行