Skip to content

Commit

Permalink
Fixed #1, the resource files are now read with UTF-8
Browse files Browse the repository at this point in the history
  • Loading branch information
vatbub committed May 16, 2017
1 parent 5cca26f commit 2212ae6
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/main/java/com/github/vatbub/randomusers/data/DataSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,37 +63,37 @@ public static DataSet loadWithoutCache(Nationality nationality) {

String resourcePackage = nationality.getShortCode() + "/lists";

Scanner scanner = new Scanner(DataSet.class.getResourceAsStream(resourcePackage + "/cities.txt"));
Scanner scanner = new Scanner(DataSet.class.getResourceAsStream(resourcePackage + "/cities.txt"), "UTF-8");
res.cities = new ArrayList<>();
while (scanner.hasNextLine()) {
res.cities.add(scanner.nextLine());
}

scanner = new Scanner(DataSet.class.getResourceAsStream(resourcePackage + "/female_first.txt"));
scanner = new Scanner(DataSet.class.getResourceAsStream(resourcePackage + "/female_first.txt"), "UTF-8");
res.femaleFirst = new ArrayList<>();
while (scanner.hasNextLine()) {
res.femaleFirst.add(scanner.nextLine());
}

scanner = new Scanner(DataSet.class.getResourceAsStream(resourcePackage + "/male_first.txt"));
scanner = new Scanner(DataSet.class.getResourceAsStream(resourcePackage + "/male_first.txt"), "UTF-8");
res.maleFirst = new ArrayList<>();
while (scanner.hasNextLine()) {
res.maleFirst.add(scanner.nextLine());
}

scanner = new Scanner(DataSet.class.getResourceAsStream(resourcePackage + "/last.txt"));
scanner = new Scanner(DataSet.class.getResourceAsStream(resourcePackage + "/last.txt"), "UTF-8");
res.last = new ArrayList<>();
while (scanner.hasNextLine()) {
res.last.add(scanner.nextLine());
}

scanner = new Scanner(DataSet.class.getResourceAsStream(resourcePackage + "/states.txt"));
scanner = new Scanner(DataSet.class.getResourceAsStream(resourcePackage + "/states.txt"), "UTF-8");
res.states = new ArrayList<>();
while (scanner.hasNextLine()) {
res.states.add(scanner.nextLine());
}

scanner = new Scanner(DataSet.class.getResourceAsStream(resourcePackage + "/street.txt"));
scanner = new Scanner(DataSet.class.getResourceAsStream(resourcePackage + "/street.txt"), "UTF-8");
res.street = new ArrayList<>();
while (scanner.hasNextLine()) {
res.street.add(scanner.nextLine());
Expand Down Expand Up @@ -136,31 +136,31 @@ public static class CommonDataSet {
private static List<String> user2;

private static void loadPasswords() {
Scanner scanner = new Scanner(DataSet.class.getResourceAsStream("common/lists/passwords.txt"));
Scanner scanner = new Scanner(DataSet.class.getResourceAsStream("common/lists/passwords.txt"), "UTF-8");
passwords = new ArrayList<>();
while (scanner.hasNextLine()) {
passwords.add(scanner.nextLine());
}
}

private static void loadTitle() {
Scanner scanner = new Scanner(DataSet.class.getResourceAsStream("common/lists/title.txt"));
Scanner scanner = new Scanner(DataSet.class.getResourceAsStream("common/lists/title.txt"), "UTF-8");
title = new ArrayList<>();
while (scanner.hasNextLine()) {
title.add(scanner.nextLine());
}
}

private static void loadUser1() {
Scanner scanner = new Scanner(DataSet.class.getResourceAsStream("common/lists/user1.txt"));
Scanner scanner = new Scanner(DataSet.class.getResourceAsStream("common/lists/user1.txt"), "UTF-8");
user1 = new ArrayList<>();
while (scanner.hasNextLine()) {
user1.add(scanner.nextLine());
}
}

private static void loadUser2() {
Scanner scanner = new Scanner(DataSet.class.getResourceAsStream("common/lists/user2.txt"));
Scanner scanner = new Scanner(DataSet.class.getResourceAsStream("common/lists/user2.txt"), "UTF-8");
user2 = new ArrayList<>();
while (scanner.hasNextLine()) {
user2.add(scanner.nextLine());
Expand Down

0 comments on commit 2212ae6

Please sign in to comment.