File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
java/com/itextpdf/io/util
resources/com/itextpdf/io/util Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,10 @@ This file is part of the iText (R) project.
46
46
import com .itextpdf .test .annotations .type .UnitTest ;
47
47
import java .io .File ;
48
48
import java .io .IOException ;
49
+ import java .io .InputStream ;
50
+ import java .net .MalformedURLException ;
51
+ import java .net .URL ;
52
+ import java .nio .charset .StandardCharsets ;
49
53
import java .nio .file .Paths ;
50
54
import org .junit .Assert ;
51
55
import org .junit .BeforeClass ;
@@ -86,4 +90,14 @@ public void nullBaseUriTest() throws IOException {
86
90
File tempFile = null ;
87
91
Assert .assertEquals (expected , FileUtil .getParentDirectory (tempFile ));
88
92
}
93
+
94
+ @ Test
95
+ public void openStreamTest () throws IOException {
96
+ String resPath = "./src/test/resources/com/itextpdf/io/util/textFile.dat" ;
97
+ InputStream openStream = UrlUtil .openStream (new File (resPath ).toURI ().toURL ());
98
+
99
+ String actual = new String (StreamUtil .inputStreamToArray (openStream ), StandardCharsets .UTF_8 );
100
+ Assert .assertEquals ("Hello world from text file!" , actual );
101
+
102
+ }
89
103
}
Original file line number Diff line number Diff line change
1
+ Hello world from text file!
You can’t perform that action at this time.
0 commit comments