本文整理了Java中org.apache.mina.common.ByteBuffer.putString()
方法的一些代码示例,展示了ByteBuffer.putString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuffer.putString()
方法的具体详情如下:
包路径:org.apache.mina.common.ByteBuffer
类名称:ByteBuffer
方法名:putString
[英]Writes the content of in
into this buffer as a NUL
-terminated string using the specified encoder
.
If the charset name of the encoder is UTF-16, you cannot specify odd fieldSize
, and this method will append two NUL
s as a terminator.
Please note that this method doesn't terminate with NUL
if the input string is longer than fieldSize.
[中]使用指定的encoder
将in
的内容作为NUL
终止的字符串写入此缓冲区。
如果编码器的字符集名称为UTF-16,则不能指定奇数fieldSize
,此方法将附加两个NUL
作为终止符。
请注意,如果输入字符串长于fieldSize,则此方法不会以NUL
终止。
代码示例来源:origin: org.apache.directory.mina/mina-core
public ByteBuffer putString( CharSequence in, CharsetEncoder encoder )
throws CharacterCodingException
{
buf.putString( in, encoder );
return this;
}
代码示例来源:origin: org.apache.directory.mina/mina-core
public ByteBuffer putString( CharSequence in, int fieldSize,
CharsetEncoder encoder )
throws CharacterCodingException
{
buf.putString( in, fieldSize, encoder );
return this;
}
代码示例来源:origin: org.apache.directory.server/mitosis
protected void encodeBody( BaseMessage in, ByteBuffer out )
{
LoginMessage m = ( LoginMessage ) in;
try
{
out.putString( m.getReplicaId(), utf8encoder );
}
catch ( CharacterCodingException e )
{
throw new RuntimeException( e );
}
}
代码示例来源:origin: org.apache.directory.server/mitosis
protected void encodeBody( BaseMessage in, ByteBuffer out ) throws Exception
{
LoginAckMessage m = ( LoginAckMessage ) in;
super.encodeBody( in, out );
out.putString( m.getReplicaId(), utf8encoder );
}
代码示例来源:origin: org.apache.directory.mina/mina-core
public void encode( IoSession session, Object message,
ProtocolEncoderOutput out )
throws Exception
{
CharsetEncoder encoder = ( CharsetEncoder ) session.getAttribute( ENCODER );
if( encoder == null )
{
encoder = charset.newEncoder();
session.setAttribute( ENCODER, encoder );
}
String value = message.toString();
ByteBuffer buf = ByteBuffer.allocate( value.length() ).setAutoExpand( true );
buf.putString( value, encoder );
if( buf.position() > maxLineLength )
{
throw new IllegalArgumentException( "Line length: " + buf.position() );
}
buf.putString( delimiter.getValue(), encoder );
buf.flip();
out.write( buf );
}
代码示例来源:origin: org.apache.directory.server/mitosis
private void writeCSNVector( ByteBuffer out, CSNVector csns )
{
Set<String> replicaIds = csns.getReplicaIds();
int nReplicas = replicaIds.size();
out.putInt( nReplicas );
for ( String replicaId:replicaIds )
{
CSN csn = csns.getCSN( replicaId );
try
{
out.putString( replicaId, utf8encoder );
out.put( ( byte ) 0x00 );
out.putLong( csn.getTimestamp() );
out.putInt( csn.getOperationSequence() );
}
catch ( CharacterCodingException e )
{
throw new RuntimeException( e );
}
}
}
代码示例来源:origin: org.apache.directory.mina/mina-core
tmp.putString( delimiter.getValue(), charset.newEncoder() );
tmp.flip();
delimBuf = tmp;
内容来源于网络,如有侵权,请联系作者删除!