Monday, February 20, 2012

Put a StringBuffer in a ByteBuffer


I am trying to put a string buffer in a bytebuffer..




out.put(ss);



where out is a ByteBuffer and ss is a StringBuffer. Is there any easy way to do this? Assuming ASCII encoding for the string.



Thanks

1 comment:

  1. StringBuffer buf = ...;
    byte[] bytes = buf.toString().getBytes("US-ASCII");


    or possibly "ISO-8859-1"

    ReplyDelete