|
|
|
@ -4,11 +4,8 @@ import org.apache.commons.io.IOUtils;
|
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.net.URI; |
|
|
|
|
import java.net.URISyntaxException; |
|
|
|
|
import java.net.URL; |
|
|
|
|
import java.nio.file.Path; |
|
|
|
|
import java.nio.file.Paths; |
|
|
|
|
|
|
|
|
|
import static java.lang.ClassLoader.getSystemResource; |
|
|
|
|
import static java.lang.ClassLoader.getSystemResourceAsStream; |
|
|
|
@ -18,18 +15,16 @@ public class ResourceHelpers {
|
|
|
|
|
try { |
|
|
|
|
return IOUtils.toString(getSystemResourceAsStream(resource)); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
throw new AssertionError("Resource not found", e); |
|
|
|
|
throw new AssertionError("Resource not found: " + e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static File resourceAsFile(String resource) { |
|
|
|
|
try { |
|
|
|
|
URL systemResource = getSystemResource(resource); |
|
|
|
|
URI uri = systemResource.toURI(); |
|
|
|
|
Path path = Paths.get(uri); |
|
|
|
|
return path.toFile(); |
|
|
|
|
return new File(systemResource.toURI()); |
|
|
|
|
} catch (URISyntaxException e) { |
|
|
|
|
throw new AssertionError("URI syntax error", e); |
|
|
|
|
throw new AssertionError("URI syntax error:" + e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|