From 9bf03aaaca6842ba13758c6ea11753b81d71b8b3 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 5 Jun 2019 16:30:47 +0200 Subject: [PATCH] Fixed #16 Liblouis fails to initialize when there's a space in the path --- src/main/java/org/liblouis/Louis.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/liblouis/Louis.java b/src/main/java/org/liblouis/Louis.java index 586b49b..05715b1 100644 --- a/src/main/java/org/liblouis/Louis.java +++ b/src/main/java/org/liblouis/Louis.java @@ -22,6 +22,7 @@ import java.nio.file.FileVisitOption; import java.nio.file.FileVisitResult; import java.nio.file.Path; +import java.nio.file.Paths; import java.nio.file.NoSuchFileException; import java.nio.file.SimpleFileVisitor; import java.util.ArrayList; @@ -420,7 +421,7 @@ static File asFile(URL url) throws IllegalArgumentException { try { if (!"file".equals(url.getProtocol())) throw new RuntimeException("expected file URL"); - return new File(new URI("file", url.getPath(), null)); + return Paths.get(url.toURI()).toFile(); } catch (URISyntaxException e) { throw new RuntimeException(e); // should not happen }