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


Java FSTConfiguration.getObjectInput方法代码示例

本文整理汇总了Java中org.nustaq.serialization.FSTConfiguration.getObjectInput方法的典型用法代码示例。如果您正苦于以下问题:Java FSTConfiguration.getObjectInput方法的具体用法?Java FSTConfiguration.getObjectInput怎么用?Java FSTConfiguration.getObjectInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.nustaq.serialization.FSTConfiguration的用法示例。


在下文中一共展示了FSTConfiguration.getObjectInput方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.nustaq.serialization.FSTConfiguration; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    FSTConfiguration config = FSTConfiguration.createDefaultConfiguration();
    FSTObjectOutput out = config.getObjectOutput();
    out.writeObject("foobar");
    byte[] savedBuffer = out.getCopyOfWrittenBuffer();
    byte[] reallySavedBuffer = Arrays.copyOf(savedBuffer, savedBuffer.length);

    System.out.println(Arrays.equals(savedBuffer, reallySavedBuffer));

    out.resetForReUse();
    out.writeObject("blah");
    byte[] secondBuffer = out.getCopyOfWrittenBuffer();

    System.out.println(Arrays.equals(savedBuffer, reallySavedBuffer));

    config.getObjectInput(savedBuffer);
    config.getObjectInputCopyFrom(secondBuffer, 0, secondBuffer.length);
    System.out.println(Arrays.equals(savedBuffer, reallySavedBuffer));
}
 
开发者ID:RuedigerMoeller,项目名称:fast-serialization,代码行数:20,代码来源:Issue91.java

示例2: testStreamReuse

import org.nustaq.serialization.FSTConfiguration; //导入方法依赖的package包/类
@Test
public void testStreamReuse() throws Exception {
    FSTConfiguration configuration = FSTConfiguration.createDefaultConfiguration();

    String expected = "Hello, World!";
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    FSTObjectOutput fstObjectOutput = configuration.getObjectOutput(baos);
    try {
        fstObjectOutput.writeObject(expected);
    } finally {
        fstObjectOutput.flush();
    }
    byte[] serializedData = baos.toByteArray();
    FSTObjectInput input = configuration.getObjectInput(new ByteArrayInputStream(serializedData));
    Object read = input.readObject();
    Assert.assertEquals(expected, read);

    FSTObjectInput secondInput = configuration.getObjectInput(new ByteArrayInputStream(new byte[0]));
    expectedException.expect(IOException.class);
    expectedException.expectMessage("Failed to read");
    secondInput.readObject();
}
 
开发者ID:RuedigerMoeller,项目名称:fast-serialization,代码行数:23,代码来源:BasicReuseTest.java

示例3: test

import org.nustaq.serialization.FSTConfiguration; //导入方法依赖的package包/类
@Test
@Ignore
public void test() throws Throwable {
    FSTConfiguration fc = FSTConfiguration.createDefaultConfiguration();

    byte[] b;
    int len;
    try (FSTObjectOutput foo = new FSTObjectOutput(fc)) {
        foo.writeObject(new Outer());
        b = foo.getBuffer();
        len = foo.getWritten();
    }
    ByteArrayInputStream bais = new ByteArrayInputStream(b, 0, len);
    FSTObjectInput foi = fc.getObjectInput(bais);
    foi.readObject();
}
 
开发者ID:RuedigerMoeller,项目名称:fast-serialization,代码行数:17,代码来源:OverflowTest.java

示例4: testHM

import org.nustaq.serialization.FSTConfiguration; //导入方法依赖的package包/类
@Test
public void testHM() throws IOException, ClassNotFoundException {
    FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();
    HashMap hm = createHM();
    HashMap hm1 = createHM1(hm);
    FSTObjectOutput oo = conf.getObjectOutput();
    oo.writeObject(hm);
    oo.writeObject(hm1);
    byte[] copyOfWrittenBuffer = oo.getCopyOfWrittenBuffer();

    FSTObjectInput in = conf.getObjectInput(copyOfWrittenBuffer);
    Object o1 = in.readObject();
    Object o2 = in.readObject();
    Assert.assertTrue(DeepEquals.deepEquals(o1,hm));
    Assert.assertTrue(DeepEquals.deepEquals(o2,hm1));
}
 
开发者ID:RuedigerMoeller,项目名称:fast-serialization,代码行数:17,代码来源:BigObjTest.java

示例5: testCustomSerializer

import org.nustaq.serialization.FSTConfiguration; //导入方法依赖的package包/类
@Test
public void testCustomSerializer() throws Exception {
        FSTConfiguration FST = FSTConfiguration.createDefaultConfiguration();
        //FST.setForceSerializable(true);
        FST.registerSerializer(Bug34.NonSerializableClass.class, new Serializer(), false);
        FSTObjectOutput out = FST.getObjectOutput();
        out.writeObject(new Bug34.NonSerializableClass());

        FSTObjectInput in = FST.getObjectInput(out.getCopyOfWrittenBuffer());
        assertEquals(NonSerializableClass.class, in.readObject().getClass());
}
 
开发者ID:RuedigerMoeller,项目名称:fast-serialization,代码行数:12,代码来源:Bug34.java

示例6: main

import org.nustaq.serialization.FSTConfiguration; //导入方法依赖的package包/类
public static void main(String arg[]) {
        FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();

        long tim = System.currentTimeMillis();

        for ( int i = 0; i < 1000*1000; i++) {
//            conf.getObjectOutput();
            conf.getObjectInput(new byte[10]);
        }
    }
 
开发者ID:RuedigerMoeller,项目名称:fast-serialization,代码行数:11,代码来源:SetupAlloc.java


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