java create inputstream from string

Java
InputStream targetStream = new ByteArrayInputStream("your string".getBytes());

Source

Also in Java: