code: public static Observable<byte[]> encode(Observable<String> src, final CharsetEncoder charsetEncoder) {
          return src.map(new Func1<String, byte[]>() {
              @Override
              public byte[] call(String str) {
                  CharBuffer cb = CharBuffer.wrap(str);
                  ByteBuffer bb;
                  try {
                      bb = charsetEncoder.encode(cb);
                  } catch (CharacterCodingException e) {
                      throw new RuntimeException(e);
                  }
                  return Arrays.copyOfRange(bb.array(), bb.position(), bb.limit());
              }
          });
      }
docs: Encodes a possibly infinite stream of strings into an Observable of byte arrays.
  This method allows for more control over how malformed and unmappable characters are handled.
  <p>
  <img width="640" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/St.encode.png" alt="">
  
  @param src
  @param charsetEncoder
  @return the Observable with a stream of encoded byte arrays