From ffd0759d5aa5446bec5d3a915d434ff6250983bf Mon Sep 17 00:00:00 2001 From: DOHA Date: Thu, 10 Dec 2015 14:09:06 +0200 Subject: [PATCH] inputStream guava improvement --- .../org/baeldung/java/io/JavaInputStreamToXUnitTest.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java index 53bbe8a8d3..55a0904499 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaInputStreamToXUnitTest.java @@ -32,7 +32,6 @@ import com.google.common.io.ByteSource; import com.google.common.io.ByteStreams; import com.google.common.io.CharStreams; import com.google.common.io.Files; -import com.google.common.io.InputSupplier; @SuppressWarnings("unused") public class JavaInputStreamToXUnitTest { @@ -75,16 +74,14 @@ public class JavaInputStreamToXUnitTest { final String originalString = randomAlphabetic(DEFAULT_SIZE); final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); - final InputSupplier inputSupplier = new InputSupplier() { + final ByteSource byteSource = new ByteSource() { @Override - public final InputStream getInput() throws IOException { + public final InputStream openStream() throws IOException { return inputStream; } }; - final InputSupplier readerSupplier = CharStreams.newReaderSupplier(inputSupplier, Charsets.UTF_8); - // When - final String text = CharStreams.toString(readerSupplier); + final String text = byteSource.asCharSource(Charsets.UTF_8).read(); assertThat(text, equalTo(originalString)); }