Skip to content

Commit a1b1387

Browse files
author
Ilias Bartolini
committed
Fixed an exception "java.lang.IllegalArgumentException: URI is not hierarchical"
1 parent 4ed27f2 commit a1b1387

1 file changed

Lines changed: 8 additions & 15 deletions

File tree

‎koans-lib/src/com/sandwich/util/io/directories/DirectorySet.java‎

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.sandwich.util.io.directories;
22

33
import java.io.File;
4-
import java.net.URISyntaxException;
5-
import java.net.URL;
64

75
abstract class DirectorySet {
86

@@ -41,18 +39,13 @@ public String getDataDir(){
4139
}
4240

4341
private static String createBaseDir() {
44-
try {
45-
URL path = DirectorySet.class.getClassLoader().getResource(".");
46-
File dir = new File(path.toURI());
47-
if (dir.exists()) {
48-
dir = dir.getParentFile();
49-
if (dir.exists()) {
50-
dir = dir.getParentFile();
51-
}
52-
}
53-
return dir.getAbsolutePath();
54-
} catch (URISyntaxException e) {
55-
throw new RuntimeException(e);
56-
}
42+
File dir = new File(Thread.currentThread().getContextClassLoader().getResource(".").getFile());
43+
if (dir.exists()) {
44+
dir = dir.getParentFile();
45+
if (dir.exists()) {
46+
dir = dir.getParentFile();
47+
}
48+
}
49+
return dir.getAbsolutePath();
5750
}
5851
}

0 commit comments

Comments
 (0)