Ccna final exam - java, php, javascript, ios, cshap all in one. This is a collaboratively edited question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
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.
StringBuffer buf = ...;
ReplyDeletebyte[] bytes = buf.toString().getBytes("US-ASCII");
or possibly "ISO-8859-1"