Have you tried using putChar method of ByteBuffer?
ByteBuffer buf = ByteBuffer.allocate(1024);
for (char ch : myChars) {
buf.putChar(ch);
}
문제
how to write char array to java socketchannel. I am not able to write the char data to socketchannel as it takes ByteBuffer.
해결책
Have you tried using putChar method of ByteBuffer?
ByteBuffer buf = ByteBuffer.allocate(1024);
for (char ch : myChars) {
buf.putChar(ch);
}
다른 팁
Several ways eg
char[] c = {'1', '2'};
String str = new String(c);
ByteBuffer bb = Charset.defaultCharset().encode(str);
or
ByteBuffer.wrap(str.getBytes());