code: public static InputStream toInputStream(String input, String encoding) throws IOException {
          byte[] bytes = input.getBytes(Charsets.toCharset(encoding));
          return new ByteArrayInputStream(bytes);
      }
docs: -----------------------------------------------------------------------