close ( )源码实例Demo

java.io.ObjectInput#close ( )源码实例Demo

下面列出了java.io.ObjectInput#close ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: astor   文件: ArcDialFrameTests.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    ArcDialFrame f1 = new ArcDialFrame();
    ArcDialFrame 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 = (ArcDialFrame) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(f1, f2);
}
 
源代码2 项目: astor   文件: VectorTests.java
/**
 * 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);
}
 
源代码3 项目: astor   文件: YIntervalRendererTests.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    YIntervalRenderer r1 = new YIntervalRenderer();
    YIntervalRenderer 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 = (YIntervalRenderer) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(r1, r2);

}
 
源代码4 项目: astor   文件: PolynomialFunction2DTests.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    PolynomialFunction2D f1 = new PolynomialFunction2D(new double[] {1.0,
            2.0});
    PolynomialFunction2D 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 = (PolynomialFunction2D) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(f1, f2);
}
 
源代码5 项目: astor   文件: VectorSeriesTests.java
/**
 * 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);

}
 
源代码6 项目: ccu-historian   文件: TextBlockTest.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    final TextBlock b1 = new TextBlock();
    b1.addLine(new TextLine("Test"));
    TextBlock b2 = null;

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

        final ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        b2 = (TextBlock) in.readObject();
        in.close();
    }
    catch (Exception e) {
        System.out.println(e.toString());
    }
    assertEquals(b1, b2);

}
 
源代码7 项目: astor   文件: OHLCSeriesCollectionTests.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    OHLCSeriesCollection c1 = new OHLCSeriesCollection();
    OHLCSeries s1 = new OHLCSeries("Series");
    s1.add(new Year(2006), 1.0, 1.1, 1.2, 1.3);
    c1.addSeries(s1);
    OHLCSeriesCollection 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 = (OHLCSeriesCollection) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(c1, c2);
}
 
源代码8 项目: ccu-historian   文件: SpreadsheetDateTest.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    final SpreadsheetDate d1 = new SpreadsheetDate(15, 4, 2000);
    SpreadsheetDate d2 = null;

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

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

}
 
源代码9 项目: astor   文件: KeyedObjectTests.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    KeyedObject ko1 = new KeyedObject("Test", "Object");
    KeyedObject ko2 = null;

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

        ObjectInput in = new ObjectInputStream(
            new ByteArrayInputStream(buffer.toByteArray())
        );
        ko2 = (KeyedObject) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(ko1, ko2);

}
 
源代码10 项目: astor   文件: MeanAndStandardDeviationTests.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    MeanAndStandardDeviation m1 = new MeanAndStandardDeviation(1.2, 3.4);
    MeanAndStandardDeviation m2 = null;

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

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

}
 
源代码11 项目: ccu-historian   文件: RectangleEdgeTest.java
/**
 * Serialize an instance, restore it, and check for identity.
 */
public void testSerialization() {

    final RectangleEdge e1 = RectangleEdge.RIGHT;
    RectangleEdge e2 = null;

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

        final ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        e2 = (RectangleEdge) in.readObject();
        in.close();
    }
    catch (Exception e) {
        System.out.println(e.toString());
    }
    assertTrue(e1 == e2); 

}
 
源代码12 项目: astor   文件: VectorDataItemTests.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    VectorDataItem v1 = new VectorDataItem(1.0, 2.0, 3.0, 4.0);
    VectorDataItem 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 = (VectorDataItem) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(v1, v2);
}
 
源代码13 项目: astor   文件: YIntervalRendererTests.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    YIntervalRenderer r1 = new YIntervalRenderer();
    YIntervalRenderer 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 = (YIntervalRenderer) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(r1, r2);

}
 
源代码14 项目: astor   文件: DefaultKeyedValues2DDatasetTests.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    DefaultKeyedValues2DDataset d1 = new DefaultKeyedValues2DDataset();
    d1.addValue(new Double(234.2), "Row1", "Col1");
    d1.addValue(null, "Row1", "Col2");
    d1.addValue(new Double(345.9), "Row2", "Col1");
    d1.addValue(new Double(452.7), "Row2", "Col2");

    DefaultKeyedValues2DDataset d2 = null;

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

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

}
 
源代码15 项目: library   文件: YCSBServer.java
@SuppressWarnings("unchecked")
@Override
public void installSnapshot(byte[] state) {
    try {
        ByteArrayInputStream bis = new ByteArrayInputStream(state);
        ObjectInput in = new ObjectInputStream(bis);
        mTables = (TreeMap<String, YCSBTable>) in.readObject();
        in.close();
        bis.close();
    } catch (IOException | ClassNotFoundException e) {
        System.err.println("[ERROR] Error deserializing state: "
                + e.getMessage());
    }
}
 
源代码16 项目: astor   文件: CustomXYURLGeneratorTests.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    List u1 = new java.util.ArrayList();
    u1.add("URL A1");
    u1.add("URL A2");
    u1.add("URL A3");

    List u2 = new java.util.ArrayList();
    u2.add("URL B1");
    u2.add("URL B2");
    u2.add("URL B3");

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

    g1.addURLSeries(u1);
    g1.addURLSeries(u2);

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

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        g2 = (CustomXYURLGenerator) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(g1, g2);

}
 
源代码17 项目: astor   文件: CustomCategoryURLGeneratorTests.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    List u1 = new java.util.ArrayList();
    u1.add("URL A1");
    u1.add("URL A2");
    u1.add("URL A3");

    List u2 = new java.util.ArrayList();
    u2.add("URL B1");
    u2.add("URL B2");
    u2.add("URL B3");

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

    g1.addURLSeries(u1);
    g1.addURLSeries(u2);

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

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        g2 = (CustomCategoryURLGenerator) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(g1, g2);

}
 
源代码18 项目: astor   文件: DefaultPieDatasetTests.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    DefaultPieDataset d1 = new DefaultPieDataset();
    d1.setValue("C1", new Double(234.2));
    d1.setValue("C2", null);
    d1.setValue("C3", new Double(345.9));
    d1.setValue("C4", new Double(452.7));

    DefaultPieDataset d2 = null;

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

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

}
 
源代码19 项目: astor   文件: CompassPlotTests.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {

    CompassPlot p1 = new CompassPlot(null);
    p1.setRosePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, 
            Color.blue));
    p1.setRoseCenterPaint(new GradientPaint(4.0f, 3.0f, Color.red, 2.0f,
            1.0f, Color.green));
    p1.setRoseHighlightPaint(new GradientPaint(4.0f, 3.0f, Color.red, 2.0f,
            1.0f, Color.green));
    CompassPlot 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 = (CompassPlot) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(p1, p2);

}
 
源代码20 项目: JavaRushTasks   文件: Solution.java
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    this.address = (String)in.readObject();
    this.year = in.readInt();
    in.close();
}