本文整理汇总了Java中io.netty.buffer.ByteBufOutputStream.write方法的典型用法代码示例。如果您正苦于以下问题:Java ByteBufOutputStream.write方法的具体用法?Java ByteBufOutputStream.write怎么用?Java ByteBufOutputStream.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.buffer.ByteBufOutputStream
的用法示例。
在下文中一共展示了ByteBufOutputStream.write方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encode
import io.netty.buffer.ByteBufOutputStream; //导入方法依赖的package包/类
@Override
protected void encode(ChannelHandlerContext ctx, Serializable msg, ByteBuf out) throws Exception {
KryoContext kryoContext = kryoContextHolder.get();
Kryo kryo = kryoContext.getKryo();
Output output = kryoContext.getOut();
output.clear();
ByteBufOutputStream bout = new ByteBufOutputStream(out);
int startIdx = out.writerIndex();
bout.write(LENGTH_PLACEHOLDER);
output.setOutputStream(bout);
output.writeByte(StreamMessageDecoder.KRYO_STREAM_VERSION);
kryo.writeClassAndObject(output, msg);
output.flush();
bout.flush();
bout.close();
output.close();
int endIdx = out.writerIndex();
out.setInt(startIdx, endIdx - startIdx - 4);
}
示例2: writeMessage
import io.netty.buffer.ByteBufOutputStream; //导入方法依赖的package包/类
@SneakyThrows(IOException.class)
private void writeMessage(AppendBlock block, ByteBuf out) {
int startIdx = out.writerIndex();
ByteBufOutputStream bout = new ByteBufOutputStream(out);
bout.writeInt(block.getType().getCode());
bout.write(LENGTH_PLACEHOLDER);
block.writeFields(bout);
bout.flush();
bout.close();
int endIdx = out.writerIndex();
int fieldsSize = endIdx - startIdx - TYPE_PLUS_LENGTH_SIZE;
out.setInt(startIdx + TYPE_SIZE, fieldsSize + currentBlockSize);
}
示例3: encode
import io.netty.buffer.ByteBufOutputStream; //导入方法依赖的package包/类
@Override
protected void encode(ChannelHandlerContext ctx, Serializable msg, ByteBuf out) throws Exception {
int startIdx = out.writerIndex();
ByteBufOutputStream bout = new ByteBufOutputStream(out);
bout.write(LENGTH_PLACEHOLDER);
ObjectOutputStream oout = new CompactObjectOutputStream(bout);
oout.writeObject(msg);
oout.flush();
oout.close();
int endIdx = out.writerIndex();
out.setInt(startIdx, endIdx - startIdx - 4);
}
示例4: encode
import io.netty.buffer.ByteBufOutputStream; //导入方法依赖的package包/类
@Override
protected void encode(ChannelHandlerContext ctx, Serializable msg, ByteBuf out) throws Exception
{
int startIdx = out.writerIndex();
ByteBufOutputStream bout = new ByteBufOutputStream(out);
bout.write(LENGTH_PLACEHOLDER);
codec.encode(bout, msg);
int endIdx = out.writerIndex();
out.setInt(startIdx, endIdx - startIdx - 4);
}
示例5: write
import io.netty.buffer.ByteBufOutputStream; //导入方法依赖的package包/类
@Override
public void write(ByteBufOutputStream out) throws IOException {
out.write(type);
if (payload != null) {
payload.write(out);
}
}
示例6: encode
import io.netty.buffer.ByteBufOutputStream; //导入方法依赖的package包/类
@Override
protected void encode(ChannelHandlerContext ctx, Message msg, ByteBuf out) throws Exception {
int startIdx = out.writerIndex();
ByteBufOutputStream bout = new ByteBufOutputStream(out);
bout.write(LENGTH_PLACEHOLDER);
MarshalOutputStream oos = new MarshalOutputStream(bout);
oos.writeObject(msg);
oos.flush();
oos.close();
int endIdx = out.writerIndex();
out.setInt(startIdx, endIdx - startIdx - 4);
}
示例7: encode
import io.netty.buffer.ByteBufOutputStream; //导入方法依赖的package包/类
public void encode(final ByteBuf out, final Object message) throws IOException {
ByteBufOutputStream output = new ByteBufOutputStream(out);
output.write(LENGTH_PLACEHOLDER);
new KryoSerialization(kryoFactory).serialize(output, message);
}
示例8: encode
import io.netty.buffer.ByteBufOutputStream; //导入方法依赖的package包/类
public void encode(final ByteBuf out, final Object message) throws IOException {
ByteBufOutputStream bout = new ByteBufOutputStream(out);
bout.write(LENGTH_PLACEHOLDER);
KryoSerialization kryoSerialization = new KryoSerialization(kyroFactory);
kryoSerialization.serialize(bout, message);
}
示例9: writeLargeUTF
import io.netty.buffer.ByteBufOutputStream; //导入方法依赖的package包/类
/** Write a potentially long string as UTF8<br>
* The ByteBufInputStream.readUTF() and writeUTF() calls use the first two bytes of the message
* to encode the length of the string, which limits the string length to 64k.
* This method gets around that limitation by using a four byte header.
* @param s The string we are sending
* @param bbos The ByteBufOutputStream we are writing to
* @throws IOException
*/
private void writeLargeUTF(String s, ByteBufOutputStream bbos) throws IOException
{
byte[] data = s.getBytes("utf-8");
bbos.writeInt(data.length);
bbos.write(data);
}