当前位置: 首页>>代码示例>>Java>>正文


Java ByteBufOutputStream.write方法代码示例

本文整理汇总了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);
}
 
开发者ID:pulsarIO,项目名称:jetstream,代码行数:22,代码来源:KryoObjectEncoder.java

示例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);
}
 
开发者ID:pravega,项目名称:pravega,代码行数:14,代码来源:CommandEncoder.java

示例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);
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:16,代码来源:ObjectEncoder.java

示例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);
}
 
开发者ID:liulhdarks,项目名称:darks-grid,代码行数:13,代码来源:GridObjectEncoder.java

示例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);
    }
}
 
开发者ID:sk89q,项目名称:playblock,代码行数:8,代码来源:BehaviorPayload.java

示例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);
}
 
开发者ID:barakb,项目名称:asyncrmi,代码行数:16,代码来源:MessageEncoder.java

示例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);
}
 
开发者ID:terrymanu,项目名称:miracle-remote,代码行数:6,代码来源:KryoPool.java

示例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);
}
 
开发者ID:terrymanu,项目名称:miracle-framework,代码行数:7,代码来源:KryoPool.java

示例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);
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:15,代码来源:MalmoMod.java


注:本文中的io.netty.buffer.ByteBufOutputStream.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。