Commit bf433547 by Patryk Czarnik

ObslugaCSV - poprawiona wersja

parent e42a5d52
......@@ -13,9 +13,10 @@ public class ObslugaCSV {
public static List<Employee> wczytaj(String sciezka) {
List<Employee> emps = new ArrayList<>();
try (BufferedReader reader = new BufferedReader(new FileReader(sciezka))) {
reader.readLine(); // tylko po to, aby pominąć pierwszą linię
String linia;
while((linia = reader.readLine()) != null) {
String[] t = linia.split(";");
String[] t = linia.split(";", -1);
Employee emp = new Employee(Integer.parseInt(t[0]),
t[1], t[2], t[3], Integer.parseInt(t[4]),
LocalDate.parse(t[5]), t[6], t[7], t[8], t[9], t[10]);
......
package emps;
import java.util.List;
public class P0_WypiszObiekty {
public static void main(String[] args) {
List<Employee> emps = ObslugaCSV.wczytaj("pliki/emps.csv");
System.out.println("Liczba rekordów: " + emps.size());
for (Employee emp : emps) {
System.out.println(emp);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment