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
StringBuffer buf = ...;
byte[] bytes = buf.toString().getBytes("US-ASCII");
or possibly "ISO-8859-1"
String space in Java? I've heard that this can be bad for memory reasons; by calling "toString" on large bytebuffers (many MB) we cause these strings to live forever in the JVM. Am I making this up? Is there anyway to go straight from StringBuffer to Bytes?