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