Я хочу новую CUSTOMERNAME и новую линиюпрерывистых линий для каждого нового набора данных
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();
}
}