當前位置: 首頁>>代碼示例>>Java>>正文


Java Output.toBytes方法代碼示例

本文整理匯總了Java中com.esotericsoftware.kryo.io.Output.toBytes方法的典型用法代碼示例。如果您正苦於以下問題:Java Output.toBytes方法的具體用法?Java Output.toBytes怎麽用?Java Output.toBytes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.esotericsoftware.kryo.io.Output的用法示例。


在下文中一共展示了Output.toBytes方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: serialize

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
/**
 * 序列化
 *
 * @param obj 需要序更列化的對象
 * @return 序列化後的byte 數組
 * @throws TransactionException
 */
@Override
public byte[] serialize(Object obj) throws TransactionException {
    byte[] bytes;
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    try {
        //獲取kryo對象
        Kryo kryo = new Kryo();
        Output output = new Output(outputStream);
        kryo.writeObject(output, obj);
        bytes = output.toBytes();
        output.flush();
    } catch (Exception ex) {
        throw new TransactionException("kryo serialize error" + ex.getMessage());
    } finally {
        try {
            outputStream.flush();
            outputStream.close();
        } catch (IOException e) {

        }
    }
    return bytes;
}
 
開發者ID:yu199195,項目名稱:happylifeplat-transaction,代碼行數:31,代碼來源:KryoSerializer.java

示例2: serialize

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
@Override
public byte[] serialize(Object obj) throws SerializerException {
    byte[] bytes;
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    try {
        //獲取kryo對象
        Kryo kryo = new Kryo();
        Output output = new Output(outputStream);
        kryo.writeObject(output, obj);
        bytes = output.toBytes();
        output.flush();
    } catch (Exception ex) {
        throw new SerializerException("kryo serialize error" + ex.getMessage());
    } finally {
        try {
            outputStream.flush();
            outputStream.close();
        } catch (IOException e) {

        }
    }
    return bytes;
}
 
開發者ID:1991wangliang,項目名稱:tx-lcn,代碼行數:24,代碼來源:KryoSerializer.java

示例3: serialize

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
/**
 * 序列化
 *
 * @param obj 需要序更列化的對象
 * @return 序列化後的byte 數組
 * @throws TccException
 */
@Override
public byte[] serialize(Object obj) throws TccException {
    byte[] bytes;
    try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
        //獲取kryo對象
        Kryo kryo = new Kryo();
        Output output = new Output(outputStream);
        kryo.writeObject(output, obj);
        bytes = output.toBytes();
        output.flush();
    } catch (Exception ex) {
        throw new TccException("kryo serialize error" + ex.getMessage());
    }
    return bytes;
}
 
開發者ID:yu199195,項目名稱:happylifeplat-tcc,代碼行數:23,代碼來源:KryoSerializer.java

示例4: serialize

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
/**
 * 序列化
 *
 * @param obj 需要序更列化的對象
 * @return 序列化後的byte 數組
 * @throws MythException 異常
 */
@Override
public byte[] serialize(Object obj) throws MythException {
    byte[] bytes;
    try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
        //獲取kryo對象
        Kryo kryo = new Kryo();
        Output output = new Output(outputStream);
        kryo.writeObject(output, obj);
        bytes = output.toBytes();
        output.flush();
    } catch (Exception ex) {
        throw new MythException("kryo serialize error" + ex.getMessage());
    }
    return bytes;
}
 
開發者ID:yu199195,項目名稱:myth,代碼行數:23,代碼來源:KryoSerializer.java

示例5: serialize

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
@Override
public byte[] serialize(Object[] objects) {
  Output output = new Output(DEFAULT_BUFFER_SIZE, -1);

  Kryo kryo = pool.borrow();
  kryo.writeObjectOrNull(output, objects, Object[].class);
  pool.release(kryo);

  return output.toBytes();
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-saga,代碼行數:11,代碼來源:KryoMessageFormat.java

示例6: serialize

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
public byte[] serialize(T t) {
	Kryo kryo = kryoFactory.getKryo();
	try {
		Output output = new Output(1024, 1024 * 500);
		kryo.writeClassAndObject(output, t);
		return output.toBytes();
	} finally {
		kryoFactory.returnKryo(kryo);
		kryo = null;
	}
}
 
開發者ID:yaoakeji,項目名稱:hibatis,代碼行數:12,代碼來源:KryoSerializer.java

示例7: clone

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
private <T> T  clone(T obj){
	Kryo kryo = kryoFactory.getKryo();
	try {
		Output output = new Output(1024, 1024 * 500);
		kryo.writeClassAndObject(output, obj);
		output.flush();
		Input input = new Input(output.toBytes());
		T t = (T) kryo.readClassAndObject(input);
		return t;
	} finally {
		kryoFactory.returnKryo(kryo);;
	}
}
 
開發者ID:yaoakeji,項目名稱:hibatis,代碼行數:14,代碼來源:CacheContext.java


注:本文中的com.esotericsoftware.kryo.io.Output.toBytes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。