Skip to content

Commit

Permalink
Fix bug - should NOT treat resource file as a file
Browse files Browse the repository at this point in the history
  • Loading branch information
MilkBiscuit committed Apr 4, 2021
1 parent 3ccb516 commit 56ca6f5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
9 changes: 3 additions & 6 deletions src/com/cheng/rostergenerator/helper/FileHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,9 @@ public static boolean memberListFileExists() {
}

public static boolean copySampleData() {
var sourceFile = ResourceHelper.file("/memberList.json");
var sourcePath = sourceFile.toPath();
var desPath = Paths.get(MEMBER_LIST_FILE_PATH);

try {
Files.copy(sourcePath, desPath);
try (var is = FileHelper.class.getResourceAsStream("/memberList.json")) {
var desPath = Paths.get(MEMBER_LIST_FILE_PATH);
Files.copy(is, desPath);

return true;
} catch (IOException e) {
Expand Down
13 changes: 0 additions & 13 deletions src/com/cheng/rostergenerator/helper/ResourceHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,4 @@ public static ImageIcon imageIcon(String imagePath) {
return null;
}

public static File file(String path) {
try {
var resource = ResourceHelper.class.getResource(path);
var file = new File(resource.toURI());

return file;
} catch (Exception exception) {
FileHelper.printException(exception);
}

return null;
}

}

0 comments on commit 56ca6f5

Please sign in to comment.