本文整理匯總了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);
}
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}