BAEL-5015: Add Java 9 example for readAllBytes (#10999)

Co-authored-by: Krzysztof Woyke <krzysztof.woyke.sp@lhsystems.com>
This commit is contained in:
kwoyke 2021-07-06 16:54:57 +02:00 committed by GitHub
parent 1660e33cf9
commit dee85d33c1
4 changed files with 24 additions and 1 deletions

View File

@ -36,6 +36,16 @@
<build>
<finalName>core-java-io-conversions-2</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${source.version}</source>
<target>${target.version}</target>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
@ -45,6 +55,8 @@
</build>
<properties>
<source.version>11</source.version>
<target.version>11</target.version>
<json.version>20200518</json.version>
<opencsv.version>4.1</opencsv.version>
</properties>

View File

@ -70,6 +70,16 @@ public class JavaInputStreamToXUnitTest {
assertThat(text, equalTo(originalString));
}
@Test
public void givenUsingJava9_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException {
final String originalString = randomAlphabetic(DEFAULT_SIZE);
final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes());
final String text = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
assertThat(text, equalTo(originalString));
}
@Test
public final void givenUsingJava7_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException {
final String originalString = randomAlphabetic(DEFAULT_SIZE);

View File

@ -63,7 +63,6 @@
<module>core-java-io-4</module>
<module>core-java-io-apis</module>
<module>core-java-io-conversions</module>
<module>core-java-io-conversions-2</module>
<module>core-java-jar</module>
<module>core-java-jndi</module>
<module>core-java-jvm</module>

View File

@ -1292,6 +1292,7 @@
<module>core-java-modules/core-java-date-operations-1</module>
<module>core-java-modules/core-java-datetime-conversion</module>
<module>core-java-modules/core-java-datetime-string</module>
<module>core-java-modules/core-java-io-conversions-2</module>
<module>core-java-modules/core-java-jpms</module>
<module>core-java-modules/core-java-os</module>
<module>core-java-modules/core-java-string-operations-3</module>
@ -1338,6 +1339,7 @@
<module>core-java-modules/core-java-date-operations-1</module>
<module>core-java-modules/core-java-datetime-conversion</module>
<module>core-java-modules/core-java-datetime-string</module>
<module>core-java-modules/core-java-io-conversions-2</module>
<module>core-java-modules/core-java-jpms</module>
<module>core-java-modules/core-java-os</module>
<module>core-java-modules/core-java-string-operations-3</module>