UrlUtil { public static InputStream openStream(URL url) throws IOException { return url.openStream(); } private  UrlUtil(); static URL toURL(String filename); static URI toNormalizedURI(String filename); static URI toNormalizedURI(File file); static InputStream openStream(URL url); static URL getFinalURL(URL initialUrl); static String getFileUriString(String filename); static String getNormalizedFileUriString(String filename);  }
@Test public void openStreamTest() throws IOException { String resPath = "./src/test/resources/com/itextpdf/io/util/textFile.dat"; InputStream openStream = UrlUtil.openStream(new File(resPath).toURI().toURL()); String actual = new String(StreamUtil.inputStreamToArray(openStream), StandardCharsets.UTF_8); Assert.assertEquals("Hello world from text file!", actual); }