Example: Java Program to convert String to InputStream
Output
String is: nodmek InputStream: java.io.ByteArrayInputStream@5479e3f Available bytes at the beginning: 9 Available bytes at the end: 6
In the above example, we have created a string named name. Here, we have are converting the string into the input stream named stream.
The getBytes() method converts the string into bytes. To learn more, visit Java String getBytes()