aktuelle.kurse/m411/docs/Unterlagen_LB2/readFromCSVFile.java
harald.mueller@tbz.ch f300bc8c7b muh
2021-08-06 18:08:13 +02:00

17 lines
566 B
Java

public void readFromCSVFile(String filename) throws FileNotFoundException {
Scanner scanner = new Scanner(new File(filename));
scanner.nextLine(); // skip header line
while (scanner.hasNext()) {
String line = scanner.nextLine();
String[] parts = line.split(",");
String lastname = parts[0];
String firstname = parts[1];
int yearOfBirth = Integer.parseInt(parts[2]);
String pw = parts[3];
System.out.println(lastname + "/" + firstname + "/" + yearOfBirth + "/" + pw);
// Your stuff coming here
..........
}
scanner.close()
}