String to InputStream
Sometimes you need an InputStream for any method but it has a String. The following Code helps here:
String myString = "huhu"; byte[] bytes = myString.getBytes(); // with Default Encoding // byte[] bytes = myString.getBytes("UTF-8"); // with setted Encoding, here "UTF-8" InputStream is = new ByteArrayInputStream(bytes); if (is != zero) { ... }