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


Java ObjectOutput.close方法代码示例

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


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

示例1: testSerialization

import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    Vector v1 = new Vector(1.0, 2.0);
    Vector v2 = null;
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(v1);
        out.close();

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        v2 = (Vector) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(v1, v2);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:23,代码来源:VectorTests.java

示例2: testSerialization

import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    DialPlot p1 = new DialPlot();
    DialPlot p2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(p1);
        out.close();

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        p2 = (DialPlot) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(p1, p2);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:DialPlotTests.java

示例3: storePrefs

import java.io.ObjectOutput; //导入方法依赖的package包/类
void storePrefs() {
	try {
		// Serialize to a byte array
		final ByteArrayOutputStream bos = new ByteArrayOutputStream();
		final ObjectOutput oos = new ObjectOutputStream(bos);
		final Object[] hps = this.toArray();
		oos.writeObject(hps);
		oos.close();
		// Get the bytes of the serialized object
		final byte[] buf = bos.toByteArray();
		getPrefs().putByteArray("HotPixelFilter.HotPixelSet", buf);
	}
	catch (final Exception e) {
		e.printStackTrace();
	}

}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:18,代码来源:HotPixelFilter.java

示例4: testSerialization

import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    VectorSeries s1 = new VectorSeries("s1");
    s1.add(1.0, 0.5, 1.5, 2.0);
    VectorSeries s2 = null;        
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(s1);
        out.close();

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        s2 = (VectorSeries) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(s1, s2);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:VectorSeriesTests.java

示例5: putChipClassPrefs

import java.io.ObjectOutput; //导入方法依赖的package包/类
private void putChipClassPrefs() {
    try {
        // Serialize to a byte array
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(bos);
        out.writeObject(chipClassNames);
        out.close();

        // Get the bytes of the serialized object
        byte[] buf = bos.toByteArray();
        prefs.putByteArray("chipClassNames", buf);
    } catch (IOException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e2) {
        log.warning("too many classes in Preferences, " + chipClassNames.size() + " class names");
    }
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:18,代码来源:AEViewer.java

示例6: testSerialization

import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    StandardDialFrame f1 = new StandardDialFrame();
    StandardDialFrame f2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(f1);
        out.close();

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        f2 = (StandardDialFrame) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(f1, f2);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:StandardDialFrameTests.java

示例7: putArray

import java.io.ObjectOutput; //导入方法依赖的package包/类
private void putArray(int[] array, String key) {
    if ((array == null) || (key == null)) {
        log.warning("null array or key");
        return;
    }
    try {
        // Serialize to a byte array
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(bos);
        out.writeObject(array);
        out.close();

        // Get the bytes of the serialized object
        byte[] buf = bos.toByteArray();
        getPrefs().putByteArray(key, buf);
    } catch (Exception e) {
        log.warning(e.toString());
    }

}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:21,代码来源:NBFG256.java

示例8: testSerialization

import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    SignalRenderer r1 = new SignalRenderer();
    SignalRenderer r2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(r1);
        out.close();

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        r2 = (SignalRenderer) in.readObject();
        in.close();
    }
    catch (Exception e) {
        System.out.println(e.toString());
    }
    assertEquals(r1, r2);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:SignalRendererTests.java

示例9: testSerialization

import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    String[] tickLabels = new String[] {"One", "Two", "Three"};
    SymbolicAxis a1 = new SymbolicAxis("Test Axis", tickLabels);
    SymbolicAxis a2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(a1);
        out.close();

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        a2 = (SymbolicAxis) in.readObject();
        in.close();
    }
    catch (Exception e) {
        System.out.println(e.toString());
    }
    assertEquals(a1, a2);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:SymbolicAxisTests.java

示例10: testSerialization

import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    StandardCategoryLabelGenerator g1 = new StandardCategoryLabelGenerator(
        "{2}", DateFormat.getInstance()
    );
    StandardCategoryLabelGenerator g2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(g1);
        out.close();

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        g2 = (StandardCategoryLabelGenerator) in.readObject();
        in.close();
    }
    catch (Exception e) {
        System.out.println(e.toString());
    }
    assertEquals(g1, g2);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:StandardCategoryLabelGeneratorTests.java

示例11: testSerialization

import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    // test a default instance
    DialValueIndicator i1 = new DialValueIndicator(0, "Label");
    DialValueIndicator i2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(i1);
        out.close();

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        i2 = (DialValueIndicator) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(i1, i2);
    
    // test a custom instance
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:DialValueIndicatorTests.java

示例12: testSerialization

import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    StandardPieItemLabelGenerator g1 = new StandardPieItemLabelGenerator();
    StandardPieItemLabelGenerator g2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(g1);
        out.close();

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        g2 = (StandardPieItemLabelGenerator) in.readObject();
        in.close();
    }
    catch (Exception e) {
        System.out.println(e.toString());
    }
    assertEquals(g1, g2);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:StandardPieItemLabelGeneratorTests.java

示例13: testSerialization

import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    IntervalCategoryLabelGenerator g1
        = new IntervalCategoryLabelGenerator("{3} - {4}", DateFormat.getInstance());
    IntervalCategoryLabelGenerator g2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(g1);
        out.close();

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        g2 = (IntervalCategoryLabelGenerator) in.readObject();
        in.close();
    }
    catch (Exception e) {
        System.out.println(e.toString());
    }
    assertEquals(g1, g2);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:IntervalCategoryLabelGeneratorTests.java

示例14: testSerialization

import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    VectorSeries s1 = new VectorSeries("Series");
    s1.add(1.0, 1.1, 1.2, 1.3);
    VectorSeriesCollection c1 = new VectorSeriesCollection();
    c1.addSeries(s1);
    VectorSeriesCollection c2 = null;
    
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(c1);
        out.close();

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        c2 = (VectorSeriesCollection) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(c1, c2);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:VectorSeriesCollectionTests.java

示例15: close

import java.io.ObjectOutput; //导入方法依赖的package包/类
public static void close(ObjectOutput closeable) {
    if (closeable != null) {
        try {
            closeable.close();
        } catch (Exception e) {
            //can be ignored
            Log.e("IOUtils", e.getMessage());
        }
    }
}
 
开发者ID:IstiN,项目名称:android-training-2017,代码行数:11,代码来源:IOUtils.java


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