IOUtils { public static InputStream convertStringToStream(String str) { return new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8)); } private  IOUtils(); static Result<String, IOException> fetchContent(String url); static Result<InputStream, IOException> fetchContentAsStream(String url); static InputStream convertStringToStream(String str); static Result<String, IOException> convertStreamToString(InputStream inputStream); static Result<String, IOException> convertStreamToString(InputStream inputStream, Charset encoding); static void close(@Nullable Closeable closeable); static void close(@Nullable Closeable closeable, @Nullable Consumer<IOException> exceptionConsumer); static final int DEFAULT_BUFFER_SIZE; }
@Test void convertStringToStream() throws IOException { InputStream stream = IOUtils.convertStringToStream(MESSAGE); assertNotNull(stream); assertTrue(stream.available() > 0); }