File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed
core-java/src/test/java/org/baeldung/java/io Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change 3232import com .google .common .io .ByteStreams ;
3333import com .google .common .io .CharStreams ;
3434import com .google .common .io .Files ;
35- import com .google .common .io .InputSupplier ;
3635
3736@ SuppressWarnings ("unused" )
3837public class JavaInputStreamToXUnitTest {
@@ -75,16 +74,14 @@ public final void givenUsingGuava_whenConvertingAnInputStreamToAString_thenCorre
7574 final String originalString = randomAlphabetic (DEFAULT_SIZE );
7675 final InputStream inputStream = new ByteArrayInputStream (originalString .getBytes ());
7776
78- final InputSupplier < InputStream > inputSupplier = new InputSupplier < InputStream > () {
77+ final ByteSource byteSource = new ByteSource () {
7978 @ Override
80- public final InputStream getInput () throws IOException {
79+ public final InputStream openStream () throws IOException {
8180 return inputStream ;
8281 }
8382 };
84- final InputSupplier <InputStreamReader > readerSupplier = CharStreams .newReaderSupplier (inputSupplier , Charsets .UTF_8 );
8583
86- // When
87- final String text = CharStreams .toString (readerSupplier );
84+ final String text = byteSource .asCharSource (Charsets .UTF_8 ).read ();
8885
8986 assertThat (text , equalTo (originalString ));
9087 }
You can’t perform that action at this time.
0 commit comments