JavaInputStreamToXUnitTest refactor

This commit is contained in:
pivovarit 2017-05-16 09:20:54 +03:00
parent bf71b3442b
commit 924b960746
1 changed files with 3 additions and 3 deletions

View File

@ -36,7 +36,7 @@ public class JavaInputStreamToXUnitTest {
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);
}
@ -50,7 +50,7 @@ public class JavaInputStreamToXUnitTest {
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();
}
@ -81,7 +81,7 @@ public class JavaInputStreamToXUnitTest {
final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes());
// When
String text = null;
String text;
try (final Reader reader = new InputStreamReader(inputStream)) {
text = CharStreams.toString(reader);
}