JavaInputStreamToXUnitTest refactor
This commit is contained in:
parent
bf71b3442b
commit
924b960746
@ -36,7 +36,7 @@ public class JavaInputStreamToXUnitTest {
|
|||||||
|
|
||||||
final StringBuilder textBuilder = new StringBuilder();
|
final StringBuilder textBuilder = new StringBuilder();
|
||||||
try (Reader reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName(StandardCharsets.UTF_8.name())))) {
|
try (Reader reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName(StandardCharsets.UTF_8.name())))) {
|
||||||
int c = 0;
|
int c;
|
||||||
while ((c = reader.read()) != -1) {
|
while ((c = reader.read()) != -1) {
|
||||||
textBuilder.append((char) c);
|
textBuilder.append((char) c);
|
||||||
}
|
}
|
||||||
@ -50,7 +50,7 @@ public class JavaInputStreamToXUnitTest {
|
|||||||
final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); // exampleString.getBytes(StandardCharsets.UTF_8);
|
final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); // exampleString.getBytes(StandardCharsets.UTF_8);
|
||||||
|
|
||||||
// When
|
// When
|
||||||
String text = null;
|
String text;
|
||||||
try (Scanner scanner = new Scanner(inputStream, StandardCharsets.UTF_8.name())) {
|
try (Scanner scanner = new Scanner(inputStream, StandardCharsets.UTF_8.name())) {
|
||||||
text = scanner.useDelimiter("\\A").next();
|
text = scanner.useDelimiter("\\A").next();
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ public class JavaInputStreamToXUnitTest {
|
|||||||
final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes());
|
final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes());
|
||||||
|
|
||||||
// When
|
// When
|
||||||
String text = null;
|
String text;
|
||||||
try (final Reader reader = new InputStreamReader(inputStream)) {
|
try (final Reader reader = new InputStreamReader(inputStream)) {
|
||||||
text = CharStreams.toString(reader);
|
text = CharStreams.toString(reader);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user