Convert string into InputStream using ByteArrayInputStream class.
import java.io.ByteArrayInputStream; import java.io.InputStream; publicclass Main { publicstaticvoid main(String[] args)throws Exception { String text = "Converting String to InputStream Example"; InputStream is = new ByteArrayInputStream(text.getBytes("UTF-8")); } }
Related examples in the same category