You can do this:
final CharBuffer buf = CharBuffer.allocate(message.size());
for (final Character c: message)
buf.put(c.charValue());
stringMessage = new String(buf.array());
You cannot use .toArray()
directly since it would return a Character[]
, not a char[]
, and there is no String
constructor accepting a Character[]
as an argument...