如何将 String 转换为 InputStream

如何将 String exampleString = “example”; 转换为 InputStream ?

使用下面的代码进行转换:

InputStream stream = new ByteArrayInputStream(exampleString.getBytes(StandardCharsets.UTF_8));