當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。