Skip to content

Commit

Permalink
Fixed bug when loading Python scripts from jar
Browse files Browse the repository at this point in the history
  • Loading branch information
delas committed May 8, 2015
1 parent 2b3cda9 commit 65dde06
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions plg/src/plg/gui/util/collections/ScriptsCollection.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package plg.gui.util.collections;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;

/**
Expand All @@ -26,15 +25,13 @@ public class ScriptsCollection {
*/
public static String getFile(String resourceName) {
StringBuilder result = new StringBuilder("");
File file = new File(System.class.getResource(resourceName).getFile());
try (Scanner scanner = new Scanner(file)) {
InputStream is = System.class.getResourceAsStream(resourceName);
try (Scanner scanner = new Scanner(is)) {
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
result.append(line).append("\n");
}
scanner.close();
} catch (IOException e) {
e.printStackTrace();
}
return result.toString();
}
Expand Down

0 comments on commit 65dde06

Please sign in to comment.