我希望有新的客戶名稱和斷裂線
try
{
br = new BufferedReader(new FileReader(oldFileName));
bw = new BufferedWriter(new FileWriter(tmpFileName));
String line;
//bw.write("Customer Record: \r\n");
while ((line = br.readLine()) != null)
{
if (line.contains(customerName))
{
customerRecordPresentInFile = true;
line = line + "," + billAmountPayable;
}
//bw.write("\r\n");
我使用這個代碼行新的生產線,但我在文件輸出是一切都在同一行,我想打破行。
bw.write(line + "\n");
}
請對代碼進行一些更改。
if(!customerRecordPresentInFile)
{
bw.write(customerName + "-" + billAmountPayable + "\n");
}
System.out.println("\nData file updated.");
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
if(br != null) { br.close(); }
if(bw != null) { bw.close(); }
}
catch (IOException e)
{
e.printStackTrace();
}
}