diff --git a/license-maven-plugin/src/main/java/com/mycila/maven/plugin/license/util/FileUtils.java b/license-maven-plugin/src/main/java/com/mycila/maven/plugin/license/util/FileUtils.java index 62d9f7dac..e5331557b 100755 --- a/license-maven-plugin/src/main/java/com/mycila/maven/plugin/license/util/FileUtils.java +++ b/license-maven-plugin/src/main/java/com/mycila/maven/plugin/license/util/FileUtils.java @@ -23,6 +23,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.InputStreamReader; import java.io.IOException; import java.io.Reader; import java.io.UncheckedIOException; @@ -34,7 +35,6 @@ import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Map; import java.util.stream.Stream; @@ -57,14 +57,18 @@ public static void write(File file, String content, Charset encoding) throws IOE } } + private static Reader urlToReader(URL url, Charset encoding) throws IOException { + return new BufferedReader(new InputStreamReader(url.openStream(), encoding)); + } + public static String read(URL location, Charset encoding, Map properties) throws IOException, URISyntaxException { - try (Reader reader = new InterpolationFilterReader(Files.newBufferedReader(Paths.get(location.toURI()), encoding), properties)) { + try (Reader reader = new InterpolationFilterReader(urlToReader(location, encoding), properties)) { return IOUtils.toString(reader); } } public static String read(URL location, Charset encoding) throws IOException, URISyntaxException { - try (Reader reader = Files.newBufferedReader(Paths.get(location.toURI()), encoding)) { + try (Reader reader = urlToReader(location, encoding)) { return IOUtils.toString(reader); } } @@ -72,7 +76,7 @@ public static String read(URL location, Charset encoding) throws IOException, UR public static String[] read(final URL[] locations, final Charset encoding) throws IOException, URISyntaxException { final String[] results = new String[locations.length]; for (int i = 0; i < locations.length; i++) { - try (Reader reader = Files.newBufferedReader(Paths.get(locations[i].toURI()), encoding)) { + try (Reader reader = urlToReader(locations[i], encoding)) { results[i] = IOUtils.toString(reader); } }