66 lines
1.7 KiB
Java
66 lines
1.7 KiB
Java
package Uebung3_Buchungen;
|
|
|
|
import java.io.BufferedReader;
|
|
import java.io.FileReader;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
|
|
public class BuchungenAufgabe {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
ArrayList<ArrayList> overEqual100 = new ArrayList<>();
|
|
ArrayList<ArrayList> lessEqual100 = new ArrayList<>();
|
|
String dateiName = "buchungen.text";
|
|
try (BufferedReader reader = new BufferedReader(new FileReader(dateiName))){
|
|
String line;
|
|
while (( line = reader.readLine()) != null) {
|
|
// String[] split1 = line.split("\"");
|
|
// String [] split2 = split1[0].split(" ");
|
|
// String [] zsm = {split2[0], split2[1], split1[1], split1[2]};
|
|
// Buchung buchung = new Buchung("...");
|
|
ArrayList<String> data = splitIgnoringQuotes(line);
|
|
if (Double.parseDouble(data.get(3)) < 1000) {
|
|
lessEqual100.add(data);
|
|
}else {
|
|
overEqual100.add(data);
|
|
}
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
for (ArrayList arrayList : lessEqual100) {
|
|
System.out.println(arrayList.toString());
|
|
}
|
|
}
|
|
public static ArrayList<String> splitIgnoringQuotes(String input) {
|
|
ArrayList<String> parts = new ArrayList<>();
|
|
StringBuilder sb = new StringBuilder();
|
|
boolean insideQuotes = false;
|
|
|
|
for (char c : input.toCharArray()) {
|
|
if (c == '\"') {
|
|
insideQuotes = !insideQuotes;
|
|
} else if (c == ' ' && !insideQuotes) {
|
|
parts.add(sb.toString());
|
|
sb.setLength(0);
|
|
} else {
|
|
sb.append(c);
|
|
}
|
|
}
|
|
|
|
if (sb.length() > 0) {
|
|
parts.add(sb.toString());
|
|
}
|
|
|
|
return parts;
|
|
}
|
|
}
|
|
|
|
|
|
|