From 3df13417c7b103fb7c2bc50fe311eb1d9092f210 Mon Sep 17 00:00:00 2001 From: Felix Woestemeyer Date: Tue, 17 Jan 2023 16:09:55 +0100 Subject: [PATCH] =?UTF-8?q?Korrektur=20der=20Syntax=20und=20einhaltliche?= =?UTF-8?q?=20toString=20f=C3=BCr=20das=20Speichern=20der=20Daten.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Data.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Data.java b/src/Data.java index 8028ac5..f39a587 100644 --- a/src/Data.java +++ b/src/Data.java @@ -1,8 +1,9 @@ +import java.io.File; +import java.io.FileWriter; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.sql.Array; import java.util.ArrayList; import java.util.List; import java.util.Scanner; @@ -199,16 +200,20 @@ public class Data { /** * The method writeData writes the data of a List into a txt file. * + * @author Felix Wöstemeyer + * * @param pathWrite determines the filename of the file that will be written * @param listToWrite determines which ArrayList is to be used for writing the file */ public void writeData(String pathWrite, ArrayList listToWrite) { - if (pathWrite.equals("users.txt")) { - - } else if (pathWrite.equals("orders.txt")) { - - } else if (pathWrite.equals("menue.txt")){ - + try { + if (new File(pathWrite).exists()) { + for (String zeile : listToWrite) { + new FileWriter(pathWrite).write(zeile); + } + } + }catch(IOException e){ + e.printStackTrace(); } }