Получить String из ByteBuffer |
Cообщение скрыто для удобства комментирования.
Прочитать сообщение
code:
protected static String decodeString(ByteBuffer buf)
{
try
{
byte[] bytes = new byte[buf.remaining()];
buf.get(bytes);
return new String(bytes, MESSAGE_CHARSET);
} catch (UnsupportedEncodingException e)
{
throw new Error("Required character set " + MESSAGE_CHARSET +
" not found", e);
}
}
protected static ByteBuffer encodeString(String s)
{
try
{
return ByteBuffer.wrap(s.getBytes(MESSAGE_CHARSET));
} catch (UnsupportedEncodingException e)
{
throw new Error("Required character set " + MESSAGE_CHARSET +
" not found", e);
}
}
| Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |