Created
May 9, 2022 14:42
-
-
Save andcecilia/332b2791187617f27b528085902a4535 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Actress { | |
int listIndex; | |
int year; | |
int age; | |
String name; | |
String movie; | |
public Actress(){ | |
} | |
public Actress(int listIndex, int year, int age, String name, String movie) { | |
this.listIndex = listIndex; | |
this.year = year; | |
this.age = age; | |
this.name = name; | |
this.movie = movie; | |
} | |
public int getListIndex() { | |
return listIndex; | |
} | |
public void setListIndex(int listIndex) { | |
this.listIndex = listIndex; | |
} | |
public int getYear() { | |
return year; | |
} | |
public void setYear(int year) { | |
this.year = year; | |
} | |
public int getAge() { | |
return age; | |
} | |
public void setAge(int age) { | |
this.age = age; | |
} | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public String getMovie() { | |
return movie; | |
} | |
public void setMovie(String movie) { | |
this.movie = movie; | |
} | |
@Override | |
public String toString() { | |
return | |
"\n listIndex=" + listIndex + | |
", year=" + year + | |
", age=" + age + | |
", name='" + name + '\'' + | |
", movie='" + movie + '\''; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.stream.Collectors; | |
public class Main { | |
public static void main(String[] args) throws IOException { | |
List<Actress> listaAtrizes = | |
Files.lines(Paths.get("src/oscarfemale.csv")) | |
.skip(1) | |
.map(line -> line.split(";")) | |
.map(col -> new Actress(Integer.parseInt(col[0].trim()), Integer.parseInt(col[1].trim()), Integer.parseInt(col[2].trim()), col[3].trim(), col[4].trim())) | |
.collect(Collectors.toList()); | |
System.out.println(listaAtrizes); | |
listaAtrizes.stream() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment