當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。