0
將我們的ArrayList寫入文件時出現問題。 該文件保持空白。我們在代碼中找不到任何錯誤。 請幫助我們,我們的截止日期是在幾個小時內...將信息寫入文本文件
public void rapportAssortiment(String winkelNaam) throws Exception
{
ArrayList <Artikel> assortiment = db.rapportAssortiment(winkelNaam);
PrintWriter outputStream = null;
try
{
outputStream = new PrintWriter(new FileOutputStream("RapportAssortiment.txt",true));
outputStream.println("Rapport van het assortiment van winkel " + winkelNaam);
outputStream.println("Artikelnummer" + ";" + "Artikelnaam" + ";" + "Prijs" + ";" + "Aantal bonuspunten" + ";" + "Aantal bonuspunten nodig" + ";" + "Minimum aantal stuks" + ";" + "Minimum bedrag" + ";");
for(int i = 0; i< assortiment.size(); i++)
{
outputStream.println(assortiment.get(i).getArtikelNr() + ";" + assortiment.get(i).getArtikelNaam() + ";" + assortiment.get(i).getPrijs() + ";" + assortiment.get(i).getAantPunten() + ";" + assortiment.get(i).getAantPuntenNodig() + ";" + assortiment.get(i).getMinAantStuks() + ";" + assortiment.get(i).getMinBedrag());
}
}
catch(Exception exc)
{
System.out.println("Rapport trekken mislukt.");
}
}
儘量接近關閉的PrintWriter() – rickz