Skip to content
Permalink
Browse files
Get resource path from URI to avoid getting spurious leading path sep…
…arator on Windows

Reviewed-by: ehelin
  • Loading branch information
JornVernee authored and edvbld committed Aug 5, 2019
1 parent 53a6c51 commit 83ad6c8f19517698ecea635f17881ecc370c2663
Showing with 7 additions and 1 deletion.
  1. +7 −1 webrev/src/main/java/org/openjdk/skara/webrev/Webrev.java
@@ -25,6 +25,7 @@
import org.openjdk.skara.vcs.*;

import java.io.*;
import java.net.URISyntaxException;
import java.nio.channels.FileChannel;
import java.nio.file.*;
import java.util.*;
@@ -191,7 +192,12 @@ public void generate(Hash tailEnd, Hash head) throws IOException {
private void copyResource(String name) throws IOException {
var stream = this.getClass().getResourceAsStream("/" + name);
if (stream == null) {
var classPath = Path.of(getClass().getProtectionDomain().getCodeSource().getLocation().getPath());
Path classPath;
try {
classPath = Path.of(getClass().getProtectionDomain().getCodeSource().getLocation().toURI());
} catch (URISyntaxException e) {
throw new IOException(e);
}
var extPath = classPath.getParent().resolve("resources").resolve(name);
stream = new FileInputStream(extPath.toFile());
}

0 comments on commit 83ad6c8

Please sign in to comment.