当前位置: 首页>>代码示例>>Java>>正文


Java Input.close方法代码示例

本文整理汇总了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;
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:11,代码来源:KryoSerialize.java

示例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;
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:21,代码来源:KryoSerializer.java

示例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;
    }
}
 
开发者ID:teobaranga,项目名称:Catan,代码行数:18,代码来源:AccountManager.java

示例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;
}
 
开发者ID:yu199195,项目名称:happylifeplat-tcc,代码行数:21,代码来源:KryoSerializer.java

示例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();
}
 
开发者ID:martijndeh,项目名称:react-native-region-monitor,代码行数:35,代码来源:PersistableData.java

示例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);
    }
}
 
开发者ID:isfaaghyth,项目名称:Rak,代码行数:30,代码来源:PlainData.java

示例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;
}
 
开发者ID:olehmberg,项目名称:T2KMatch,代码行数:12,代码来源:KnowledgeBase.java

示例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;
}
 
开发者ID:olehmberg,项目名称:T2KMatch,代码行数:12,代码来源:WebTables.java

示例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;
}
 
开发者ID:yu199195,项目名称:myth,代码行数:21,代码来源:KryoSerializer.java

示例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;
}
 
开发者ID:tinylcy,项目名称:buddha,代码行数:9,代码来源:KryoSerializer.java

示例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;
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:16,代码来源:GdxToKryoTest.java

示例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;
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:8,代码来源:GdxToKryoTest.java

示例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;
}
 
开发者ID:craware,项目名称:webapp-tyust,代码行数:17,代码来源:KryoSerialize.java

示例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;
}
 
开发者ID:csarron,项目名称:MobiRNN-EMDL17,代码行数:39,代码来源:Util.java

示例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);
//        }


    }
 
开发者ID:csarron,项目名称:MobiRNN-EMDL17,代码行数:35,代码来源:DataUtilTest.java


注:本文中的com.esotericsoftware.kryo.io.Input.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。