Java: Convert String to InputStream

Some methods want an InputStream, converting a String into an InputStream is very easy:

/**
 * Converts a string into an inputstream
 * @param s
 * @return
 */
private InputStream convertStringToInputStream(String s) {
  ByteArrayInputStream in = new ByteArrayInputStream(s.getBytes());
  return in;
}

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert