Skip to content

Commit

Permalink
JavaInputStreamToXUnitTest refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
pivovarit committed May 16, 2017
1 parent bf71b34 commit 924b960
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public final void givenUsingJava5_whenConvertingAnInputStreamToAString_thenCorre

final StringBuilder textBuilder = new StringBuilder();
try (Reader reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName(StandardCharsets.UTF_8.name())))) {
int c = 0;
int c;
while ((c = reader.read()) != -1) {
textBuilder.append((char) c);
}
Expand All @@ -50,7 +50,7 @@ public final void givenUsingJava7_whenConvertingAnInputStreamToAString_thenCorre
final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); // exampleString.getBytes(StandardCharsets.UTF_8);

// When
String text = null;
String text;
try (Scanner scanner = new Scanner(inputStream, StandardCharsets.UTF_8.name())) {
text = scanner.useDelimiter("\\A").next();
}
Expand Down Expand Up @@ -81,7 +81,7 @@ public final void givenUsingGuavaAndJava7_whenConvertingAnInputStreamToAString_t
final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes());

// When
String text = null;
String text;
try (final Reader reader = new InputStreamReader(inputStream)) {
text = CharStreams.toString(reader);
}
Expand Down

0 comments on commit 924b960

Please sign in to comment.