static wurde der methode readdata ergänzt

This commit is contained in:
Kevin Pfannenstiel 2022-11-28 10:43:34 +01:00
parent 27f72a7766
commit 72f3ed5ba6
2 changed files with 6 additions and 6 deletions

View File

@ -41,13 +41,13 @@ public class GeneralMethods {
* @param pathRead determines the filename of the file that will be read * @param pathRead determines the filename of the file that will be read
* @return menueList, userList, orderList depending on Data read * @return menueList, userList, orderList depending on Data read
*/ */
public ArrayList<String> readData(String pathRead) { public static ArrayList<String> readData(String pathRead) {
Path path = Paths.get(pathRead); Path path = Paths.get(pathRead);
try { try {
List<String> rows = Files.readAllLines(path); List<String> rows = Files.readAllLines(path);
if (pathRead == "menue.txt") { if (pathRead.equals("menue.txt")) {
ArrayList<String> menueList = new ArrayList<>(); ArrayList<String> menueList = new ArrayList<>();
for (String row : rows) { for (String row : rows) {
@ -64,7 +64,7 @@ public class GeneralMethods {
} }
return menueList; return menueList;
} else if (pathRead == "users.txt") { } else if (pathRead.equals("users.txt")){
ArrayList<String> userList = new ArrayList<>(); ArrayList<String> userList = new ArrayList<>();
for (String row : rows) { for (String row : rows) {
@ -79,7 +79,7 @@ public class GeneralMethods {
} }
return userList; return userList;
} else if (pathRead == "orders.txt") { } else if (pathRead.equals("orders.txt")) {
ArrayList<String> orderList = new ArrayList<>(); ArrayList<String> orderList = new ArrayList<>();
for (String row : rows) { for (String row : rows) {
@ -113,9 +113,9 @@ public class GeneralMethods {
* @param listToWrite determines which ArrayList is to be used for writing the file * @param listToWrite determines which ArrayList is to be used for writing the file
*/ */
public void writeData2 (String pathWrite, ArrayList<String> listToWrite){ public void writeData2 (String pathWrite, ArrayList<String> listToWrite){
if (pathWrite == "users.txt") { if (pathWrite.equals("users.txt")) {
} else if (pathWrite == "orders.txt") { } else if (pathWrite.equals("orders.txt")) {
} }
} }