本文整理匯總了Java中com.esotericsoftware.kryo.io.Input.close方法的典型用法代碼示例。如果您正苦於以下問題:Java Input.close方法的具體用法?Java Input.close怎麽用?Java Input.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.esotericsoftware.kryo.io.Input
的用法示例。
在下文中一共展示了Input.close方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: deserialize
import com.esotericsoftware.kryo.io.Input; //導入方法依賴的package包/類
@Override
public Object deserialize(InputStream input) throws IOException {
Kryo kryo = pool.borrow();
Input in = new Input(input);
Object result = kryo.readClassAndObject(in);
in.close();
input.close();
pool.release(kryo);
return result;
}
示例2: deSerialize
import com.esotericsoftware.kryo.io.Input; //導入方法依賴的package包/類
/**
* 反序列化
*
* @param param 需要反序列化的byte []
* @return 序列化對象
* @throws TransactionException
*/
@Override
public <T> T deSerialize(byte[] param, Class<T> clazz) throws TransactionException {
T object;
try(ByteArrayInputStream inputStream=new ByteArrayInputStream(param)) {
Kryo kryo = new Kryo();
Input input = new Input(inputStream);
object = kryo.readObject(input, clazz);
input.close();
} catch (Exception e) {
throw new TransactionException("kryo deSerialize error" + e.getMessage());
}
return object;
}
示例3: getLocalAccount
import com.esotericsoftware.kryo.io.Input; //導入方法依賴的package包/類
/**
* Retrieve the account that was previously used to log in
*
* @return the local account if it exists, null otherwise
*/
public static Account getLocalAccount() {
try {
final Kryo kryo = CatanGame.client.getKryo();
final Input input = new Input(new FileInputStream(ACCOUNT_PATH));
final Account account = kryo.readObject(input, Account.class);
input.close();
return account;
} catch (FileNotFoundException e) {
System.out.println("Cached account not found");
return null;
}
}
示例4: deSerialize
import com.esotericsoftware.kryo.io.Input; //導入方法依賴的package包/類
/**
* 反序列化
*
* @param param 需要反序列化的byte []
* @return 序列化對象
* @throws TccException
*/
@Override
public <T> T deSerialize(byte[] param, Class<T> clazz) throws TccException {
T object;
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(param)) {
Kryo kryo = new Kryo();
Input input = new Input(inputStream);
object = kryo.readObject(input, clazz);
input.close();
} catch (Exception e) {
throw new TccException("kryo deSerialize error" + e.getMessage());
}
return object;
}
示例5: load
import com.esotericsoftware.kryo.io.Input; //導入方法依賴的package包/類
@NonNull
public static PersistableData load(@NonNull Context context)
{
Kryo serialiser = createSerialiser();
String path = context.getFilesDir().getAbsolutePath() + "/" + CACHE_FILE;
Log.d(TAG, "Attempt to load geofencing state from " + path);
if (new File(path).exists())
{
try
{
Input input = new Input(new FileInputStream(path));
PersistableData data = serialiser.readObject(input, PersistableData.class);
input.close();
if (data != null)
{
Log.d(TAG, "Successfully loaded geoencing data... " + data);
return data;
}
}
catch (Exception e)
{
Log.e(TAG, "Could not deserialise geofencing data", e);
}
}
else
{
Log.i(TAG, "No geofencing data to load");
}
return new PersistableData();
}
示例6: readTable
import com.esotericsoftware.kryo.io.Input; //導入方法依賴的package包/類
private <E> E readTable(String key, File originalFile,
boolean v1CompatibilityMode) {
try {
final Input i = new Input(new FileInputStream(originalFile));
final Kryo kryo = getKryo();
if (v1CompatibilityMode) {
kryo.getFieldSerializerConfig().setOptimizedGenerics(true);
}
final RakTable<E> paperTable = kryo.readObject(i, RakTable.class);
i.close();
if (v1CompatibilityMode) {
kryo.getFieldSerializerConfig().setOptimizedGenerics(false);
}
return paperTable.content;
} catch (FileNotFoundException | KryoException | ClassCastException e) {
if (!v1CompatibilityMode) {
return readTable(key, originalFile, true);
}
if (originalFile.exists()) {
if (!originalFile.delete()) {
throw new RuntimeException("cant deleted file "
+ originalFile, e);
}
}
String errorMessage = "cant read file "
+ originalFile + " for table " + key;
throw new RuntimeException(errorMessage, e);
}
}
示例7: deserialise
import com.esotericsoftware.kryo.io.Input; //導入方法依賴的package包/類
public static KnowledgeBase deserialise(File location) throws FileNotFoundException {
System.out.println("Deserialising Knowledge Base");
Kryo kryo = KryoFactory.createKryoInstance();
Input input = new Input(new FileInputStream(location));
KnowledgeBase kb = kryo.readObject(input, KnowledgeBase.class);
input.close();
return kb;
}
示例8: deserialise
import com.esotericsoftware.kryo.io.Input; //導入方法依賴的package包/類
public static WebTables deserialise(File location) throws FileNotFoundException {
System.out.println("Deserialising Web Tables");
Kryo kryo = KryoFactory.createKryoInstance();
Input input = new Input(new FileInputStream(location));
WebTables web = kryo.readObject(input, WebTables.class);
input.close();
return web;
}
示例9: deSerialize
import com.esotericsoftware.kryo.io.Input; //導入方法依賴的package包/類
/**
* 反序列化
*
* @param param 需要反序列化的byte []
* @return 序列化對象
* @throws MythException 異常
*/
@Override
public <T> T deSerialize(byte[] param, Class<T> clazz) throws MythException {
T object;
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(param)) {
Kryo kryo = new Kryo();
Input input = new Input(inputStream);
object = kryo.readObject(input, clazz);
input.close();
} catch (Exception e) {
throw new MythException("kryo deSerialize error" + e.getMessage());
}
return object;
}
示例10: deserialize
import com.esotericsoftware.kryo.io.Input; //導入方法依賴的package包/類
public <T> T deserialize(byte[] bytes, Class<T> clazz) {
Kryo kryo = new Kryo();
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
Input input = new Input(bais);
T result = kryo.readObject(input, clazz);
input.close();
return result;
}
示例11: simpleRoundTrip
import com.esotericsoftware.kryo.io.Input; //導入方法依賴的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;
}
示例12: read
import com.esotericsoftware.kryo.io.Input; //導入方法依賴的package包/類
<T> T read (byte[] bytes, Class<T> type){
ByteArrayInputStream inStream = new ByteArrayInputStream(bytes);
Input input = new Input(inStream);
T object = (T)kryo.readClassAndObject(input);
input.close();
return object;
}
示例13: deserialize
import com.esotericsoftware.kryo.io.Input; //導入方法依賴的package包/類
/**
* kryo反序列化
* @param input
* @return
* @throws IOException
*/
@Override
public Object deserialize(InputStream input) throws IOException {
Kryo kryo = pool.borrow();
Input in = new Input(input);
Object object = kryo.readClassAndObject(in);
in.close();
input.close();
pool.release(kryo);
return object;
}
示例14: getInputData
import com.esotericsoftware.kryo.io.Input; //導入方法依賴的package包/類
public static float[][][] getInputData(String folder) throws IOException {
if (cachedInputs != null) {
return cachedInputs;
}
final float[][][] inputs;
final Kryo kryo = new Kryo();
kryo.register(float[][][].class);
final File dataBinFile = new File(getDataPath() + File.separator + "data-small.bin");
if (dataBinFile.exists()) {
Logger.i("begin reading input data bin: %s", dataBinFile.getAbsolutePath());
Input input = new Input(new FileInputStream(dataBinFile));
inputs = kryo.readObject(input, float[][][].class);
input.close();
Logger.i("begin reading input data bin: %s", dataBinFile.getAbsolutePath());
} else {
Logger.i("begin parsing input data");
String inputFilePath =
folder + File.separator + "test_data" + File.separator + "sensor";
inputs = parseInputData(inputFilePath);
Logger.i("end parsing input data");
new Thread(new Runnable() {
@Override
public void run() {
try {
Output output = new Output(new FileOutputStream(dataBinFile));
kryo.writeObject(output, inputs);
output.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}).start();
}
cachedInputs = inputs;
return cachedInputs;
}
示例15: serialize
import com.esotericsoftware.kryo.io.Input; //導入方法依賴的package包/類
@Test
public void serialize() throws Exception {
String testFilePath = getClass().getClassLoader().getResource("lstm_har-data").getFile();
String inputFilePath =
testFilePath + File.separator + "test_data" + File.separator + "sensor";
final float[][][] inputs;
final Kryo kryo = new Kryo();
kryo.register(float[][][].class);
final File dataBinFile = new File("data-small.bin");
if (dataBinFile.exists()) {
Input input = new Input(new FileInputStream(dataBinFile));
inputs = kryo.readObject(input, float[][][].class);
input.close();
} else {
inputs = DataUtil.parseInputData(inputFilePath);
Output output = new Output(new FileOutputStream(dataBinFile));
kryo.writeObject(output, inputs);
output.close();
}
// Gson gson = new Gson();
// final File dataBinFile = new File("data.json");
// if (dataBinFile.exists()) {
// inputs = gson.fromJson(FileUtils.readFileToString(dataBinFile), float[][][].class);
// } else {
// inputs = DataUtil.parseInputData(inputFilePath);
// String result = gson.toJson(inputs);
// FileUtils.writeStringToFile(new File("data.json"), result);
// }
}