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


Java Output.close方法代碼示例

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


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

示例1: encode

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
@Override
public ByteBuf encode(Object in) throws IOException {
    Kryo kryo = null;
    ByteBuf out = ByteBufAllocator.DEFAULT.buffer();
    try {
        ByteBufOutputStream baos = new ByteBufOutputStream(out);
        Output output = new Output(baos);
        kryo = kryoPool.get();
        kryo.writeClassAndObject(output, in);
        output.close();
        return baos.buffer();
    } catch (Exception e) {
        out.release();
        if (e instanceof RuntimeException) {
            throw (RuntimeException) e;
        }
        throw new RedissonKryoCodecException(e);
    } finally {
        if (kryo != null) {
            kryoPool.yield(kryo);
        }
    }
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:24,代碼來源:KryoCodec.java

示例2: save

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
public void save(@NonNull Context context)
{
	Kryo serialiser = createSerialiser();

	Log.d(TAG, "Save geofencing state... ");
	String path = context.getFilesDir().getAbsolutePath() + "/" + CACHE_FILE;
	Log.d(TAG, "Saving geofencing state to" + path);
	try
	{
		Output output = new Output(new FileOutputStream(path));
		serialiser.writeObject(output, this);
		output.close();
	}
	catch (FileNotFoundException e)
	{
		Log.e(TAG, "Could not serialise geofencing data", e);
	}
}
 
開發者ID:martijndeh,項目名稱:react-native-region-monitor,代碼行數:19,代碼來源:PersistableData.java

示例3: writeTable

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
private <E> void writeTable(String key, RakTable<E> paperTable, File originalFile, File backupFile) {
    try {
        FileOutputStream file = new FileOutputStream(originalFile);
        final Output kryoOutput = new Output(file);
        getKryo().writeObject(kryoOutput, paperTable);
        kryoOutput.flush();
        file.flush();
        sync(file);
        kryoOutput.close();
        backupFile.delete();
    } catch (IOException e) {
        if (originalFile.exists()) {
            if (!originalFile.delete()) {
                throw new RuntimeException("cant deleted");
            }
        }
        throw new RuntimeException("cant save to table " + key, e);
    }
}
 
開發者ID:isfaaghyth,項目名稱:Rak,代碼行數:20,代碼來源:PlainData.java

示例4: serialize

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
public byte[] serialize(Object object) {
    Kryo kryo = new Kryo();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Output output = new Output(baos);
    kryo.writeObject(output, object);
    output.flush();
    output.close();
    byte[] bytes = baos.toByteArray();
    try {
        baos.flush();
        baos.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return bytes;
}
 
開發者ID:tinylcy,項目名稱:buddha,代碼行數:17,代碼來源:KryoSerializer.java

示例5: apply

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
@Override
public byte[] apply(Object value) {
    try {
        Kryo kryo = kryoThreadLocal.get();
        ByteArrayOutputStream bos = new ByteArrayOutputStream(256);
        Output output = new Output(bos);
        output.writeInt(IDENTITY_NUMBER);
        kryo.writeClassAndObject(output, value);
        output.close();
        return bos.toByteArray();
    } catch (Exception e) {
        StringBuilder sb = new StringBuilder("Kryo Encode error. ");
        sb.append("msg=").append(e.getMessage());
        throw new CacheEncodeException(sb.toString(), e);
    }
}
 
開發者ID:alibaba,項目名稱:jetcache,代碼行數:17,代碼來源:KryoValueEncoder.java

示例6: serializationObject

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
private byte[] serializationObject(Kryo kryo, byte[] obj) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Output output = new Output(baos);
    kryo.writeClassAndObject(output, obj);
    output.flush();
    output.close();

    byte[] b = baos.toByteArray();
    try {
        baos.flush();
        baos.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return b;
}
 
開發者ID:PAA-NCIC,項目名稱:SparkSeq,代碼行數:18,代碼來源:TestKryo.java

示例7: serializationObject

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
private <T extends Serializable> byte[] serializationObject(T obj) {
    Kryo kryo = new Kryo();
    kryo.setReferences(false);
    kryo.register(obj.getClass(), new JavaSerializer());

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Output output = new Output(baos);
    kryo.writeClassAndObject(output, obj);
    output.flush();
    output.close();

    byte[] b = baos.toByteArray();
    try {
        baos.flush();
        baos.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return b;
}
 
開發者ID:PAA-NCIC,項目名稱:SparkSeq,代碼行數:22,代碼來源:TestMapDataSerialization.java

示例8: serialize

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
@Override
public void serialize(OutputStream output, Object object) throws IOException {
    Kryo kryo = pool.borrow();
    Output out = new Output(output);
    kryo.writeClassAndObject(out, object);
    out.close();
    output.close();
    pool.release(kryo);
}
 
開發者ID:yu199195,項目名稱:happylifeplat-transaction,代碼行數:10,代碼來源:KryoSerialize.java

示例9: serializeAlgoMetric

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
public static byte[] serializeAlgoMetric(Metric value) {
  Kryo kryo = getKryo();
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  Output output = new Output(baos);
  kryo.writeClassAndObject(output, value);
  output.flush();
  output.close();
  return baos.toByteArray();
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:10,代碼來源:KryoUtils.java

示例10: serialize

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
@Override
public byte[] serialize(T packet) {
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	Output out = new UnsafeOutput(baos);
	kryo.writeClassAndObject(out, packet);
	out.close();
	return baos.toByteArray();
}
 
開發者ID:BRjDevs,項目名稱:BRjLibs,代碼行數:9,代碼來源:KryoUnsafePacketFactory.java

示例11: serialize

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
@Override
public byte[] serialize(T packet) {
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	Output out = new Output(baos);
	synchronized (kryo) {
		kryo.writeClassAndObject(out, packet);
	}
	out.close();
	return baos.toByteArray();
}
 
開發者ID:BRjDevs,項目名稱:BRjLibs,代碼行數:11,代碼來源:KryoPacketFactory.java

示例12: serialise

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
public void serialise(File location) throws FileNotFoundException {
	System.out.println("Serialising Knowledge Base");
	
       Kryo kryo = KryoFactory.createKryoInstance();
       Output output = new Output(new FileOutputStream(location));
       kryo.writeObject(output, this);
       output.close();
}
 
開發者ID:olehmberg,項目名稱:T2KMatch,代碼行數:9,代碼來源:KnowledgeBase.java

示例13: serialise

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
public void serialise(File location) throws FileNotFoundException {
	System.out.println("Serialising Web Tables");
	
       Kryo kryo = KryoFactory.createKryoInstance();
       Output output = new Output(new FileOutputStream(location));
       kryo.writeObject(output, this);
       output.close();
}
 
開發者ID:olehmberg,項目名稱:T2KMatch,代碼行數:9,代碼來源:WebTables.java

示例14: simpleRoundTrip

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
<T> T simpleRoundTrip (T object){
    ByteArrayOutputStream outStream = new ByteArrayOutputStream();
    Output output = new Output(outStream);
    kryo.writeClassAndObject(output, object);
    output.close();
    byte[] outBytes = outStream.toByteArray();

    ByteArrayInputStream inStream = new ByteArrayInputStream(outBytes);
    Input input = new Input(inStream);
    T object1 = (T)kryo.readClassAndObject(input);
    input.close();

    assertTrue(equals(object, object1));
    return object1;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:16,代碼來源:GdxToKryoTest.java

示例15: write

import com.esotericsoftware.kryo.io.Output; //導入方法依賴的package包/類
byte[] write (Object object){
    ByteArrayOutputStream outStream = new ByteArrayOutputStream();
    Output output = new Output(outStream);
    kryo.writeClassAndObject(output, object);
    output.close();
    return outStream.toByteArray();
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:8,代碼來源:GdxToKryoTest.java


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