We can convert Java String to Input with below approaches:
Example1:
String str = "Hello World!";
InputStream inputStream = new ByteArrayInputStream(str.getBytes());
Example 2 with UTF8:
javaCopy codeString str = "Hello World!"; InputStream inputStream = new ByteArrayInputStream(str.getBytes("
UTF-8"));
Alternatively you can see the below link to convert InputStream back to String
Thanks for Reading..