String to InputStream in Java

mport java.io.ByteArrayInputStream;
import java.io.InputStream;
 
public class StringToInputStream {
        public static void main(String args[]){
               
                String str1 = "Java convert String to InputStream Example";

                byte[] bytes = str1.getBytes();

                InputStream inputStream = new ByteArrayInputStream(bytes);
        }
}