java.beans.XMLDecoder# close ( ) 源码实例Demo

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

源代码1 项目: openjdk-jdk8u   文件: AbstractTest.java

static void test(AbstractTest object) {
    ByteArrayOutputStream output = new ByteArrayOutputStream();

    XMLEncoder encoder = new XMLEncoder(output);
    encoder.setPersistenceDelegate(
            object.getClass(),
            new DefaultPersistenceDelegate(new String[] {"value"}));

    encoder.writeObject(object);
    encoder.close();

    System.out.print(output);

    ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
    XMLDecoder decoder = new XMLDecoder(input);
    AbstractTest result = (AbstractTest) decoder.readObject();
    decoder.close();

    if (object.getValue() != result.getValue())
        throw new Error("Should be " + object);
}
 
源代码2 项目: TencentKona-8   文件: AbstractTest.java

static void test(AbstractTest object) {
    ByteArrayOutputStream output = new ByteArrayOutputStream();

    XMLEncoder encoder = new XMLEncoder(output);
    encoder.setPersistenceDelegate(
            object.getClass(),
            new DefaultPersistenceDelegate(new String[] {"value"}));

    encoder.writeObject(object);
    encoder.close();

    System.out.print(output);

    ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
    XMLDecoder decoder = new XMLDecoder(input);
    AbstractTest result = (AbstractTest) decoder.readObject();
    decoder.close();

    if (object.getValue() != result.getValue())
        throw new Error("Should be " + object);
}
 
源代码3 项目: openjdk-jdk9   文件: AbstractTest.java

static void test(AbstractTest object) {
    ByteArrayOutputStream output = new ByteArrayOutputStream();

    XMLEncoder encoder = new XMLEncoder(output);
    encoder.setPersistenceDelegate(
            object.getClass(),
            new DefaultPersistenceDelegate(new String[] {"value"}));

    encoder.writeObject(object);
    encoder.close();

    System.out.print(output);

    ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
    XMLDecoder decoder = new XMLDecoder(input);
    AbstractTest result = (AbstractTest) decoder.readObject();
    decoder.close();

    if (object.getValue() != result.getValue())
        throw new Error("Should be " + object);
}
 
源代码4 项目: hottub   文件: AbstractTest.java

/**
 * This is entry point to start testing.
 *
 * @param security  use {@code true} to start
 *                  second pass in secure context
 */
final void test(boolean security) {
    byte[] array = getFieldValue("XML").getBytes(); // NON-NLS: the field name
    ByteArrayInputStream input = new ByteArrayInputStream(array);
    XMLDecoder decoder = new XMLDecoder(input);
    decoder.setExceptionListener(this);
    validate(decoder);
    try {
        throw new Error("unexpected object" + decoder.readObject());
    } catch (ArrayIndexOutOfBoundsException exception) {
        // expected exception
    }
    decoder.close();
    if (security) {
        System.setSecurityManager(new SecurityManager());
        test(false);
    }
}
 
源代码5 项目: openjdk-8-source   文件: AbstractTest.java

/**
 * This is entry point to start testing.
 *
 * @param security  use {@code true} to start
 *                  second pass in secure context
 */
final void test(boolean security) {
    byte[] array = getFieldValue("XML").getBytes(); // NON-NLS: the field name
    ByteArrayInputStream input = new ByteArrayInputStream(array);
    XMLDecoder decoder = new XMLDecoder(input);
    decoder.setExceptionListener(this);
    validate(decoder);
    try {
        throw new Error("unexpected object" + decoder.readObject());
    } catch (ArrayIndexOutOfBoundsException exception) {
        // expected exception
    }
    decoder.close();
    if (security) {
        System.setSecurityManager(new SecurityManager());
        test(false);
    }
}
 
源代码6 项目: openjdk-8   文件: AbstractTest.java

/**
 * This is entry point to start testing.
 *
 * @param security  use {@code true} to start
 *                  second pass in secure context
 */
final void test(boolean security) {
    byte[] array = getFieldValue("XML").getBytes(); // NON-NLS: the field name
    ByteArrayInputStream input = new ByteArrayInputStream(array);
    XMLDecoder decoder = new XMLDecoder(input);
    decoder.setExceptionListener(this);
    validate(decoder);
    try {
        throw new Error("unexpected object" + decoder.readObject());
    } catch (ArrayIndexOutOfBoundsException exception) {
        // expected exception
    }
    decoder.close();
    if (security) {
        System.setSecurityManager(new SecurityManager());
        test(false);
    }
}
 
源代码7 项目: openjdk-8   文件: Test6341798.java

private static void test(Locale locale, byte[] data) {
    Locale.setDefault(locale);
    System.out.println("locale = " + locale);

    XMLDecoder decoder = new XMLDecoder(new ByteArrayInputStream(data));
    System.out.println("object = " + decoder.readObject());
    decoder.close();
}
 
源代码8 项目: procamtracker   文件: MainFrame.java

void loadSettings(File file) throws IOException, IntrospectionException, PropertyVetoException {
    if (file == null) {
        cameraSettings = null;
        projectorSettings = null;
        objectFinderSettings = null;
        markerDetectorSettings = null;
        alignerSettings = null;
        handMouseSettings = null;
        virtualBallSettings = null;
        realityAugmentorSettings = null;
        trackingSettings = null;

        trackingWorker = null;
    } else {
        XMLDecoder decoder = new XMLDecoder(new BufferedInputStream(new FileInputStream(file)));
        cameraSettings = (CameraDevice.Settings)decoder.readObject();
        projectorSettings = (ProjectorDevice.Settings)decoder.readObject();
        objectFinderSettings = (ObjectFinder.Settings)decoder.readObject();
        markerDetectorSettings = (MarkerDetector.Settings)decoder.readObject();
        alignerSettings = (GNImageAligner.Settings)decoder.readObject();
        handMouseSettings = (HandMouse.Settings)decoder.readObject();
        virtualBallSettings = (VirtualBall.Settings)decoder.readObject();
        realityAugmentorSettings = (RealityAugmentor.Settings)decoder.readObject();
        trackingSettings = (TrackingWorker.Settings)decoder.readObject();
        decoder.close();
    }

    settingsFile = file;
    if (settingsFile == null) {
        setTitle("ProCamTracker");
    } else {
        setTitle(settingsFile.getName() + " - ProCamTracker");
    }

    buildSettingsView();

    if (trackingWorker == null) {
        statusLabel.setText("Idling.");
    }
}
 
源代码9 项目: jdk8u-jdk   文件: Test6329581.java

private Object decode(byte[] array) {
    ByteArrayInputStream in = new ByteArrayInputStream(array);
    XMLDecoder decoder = new XMLDecoder(in, null, this, this);
    Object object = decoder.readObject();
    validate(object);
    decoder.close();
    return object;
}
 
源代码10 项目: openjdk-jdk8u   文件: Test6329581.java

private Object decode(byte[] array) {
    ByteArrayInputStream in = new ByteArrayInputStream(array);
    XMLDecoder decoder = new XMLDecoder(in, null, this, this);
    Object object = decoder.readObject();
    validate(object);
    decoder.close();
    return object;
}
 
源代码11 项目: openjdk-8-source   文件: Test4676532.java

public static void main(String[] args) throws Exception {
    StringBuilder sb = new StringBuilder(256);
    sb.append("file:");
    sb.append(System.getProperty("test.src", "."));
    sb.append(File.separatorChar);
    sb.append("test.jar");

    URL[] url = {new URL(sb.toString())};
    URLClassLoader cl = new URLClassLoader(url);

    Class type = cl.loadClass("test.Test");
    if (type == null) {
        throw new Error("could not find class test.Test");
    }


    InputStream stream = new ByteArrayInputStream(DATA.getBytes());

    ExceptionListener el = new ExceptionListener() {
        public void exceptionThrown(Exception exception) {
            throw new Error("unexpected exception", exception);
        }
    };

    XMLDecoder decoder = new XMLDecoder(stream, null, el, cl);
    Object object = decoder.readObject();
    decoder.close();

    if (!type.equals(object.getClass())) {
        throw new Error("unexpected " + object.getClass());
    }
}
 
源代码12 项目: openjdk-jdk8u-backup   文件: Test6341798.java

private static void test(Locale locale, byte[] data) {
    Locale.setDefault(locale);
    System.out.println("locale = " + locale);

    XMLDecoder decoder = new XMLDecoder(new ByteArrayInputStream(data));
    System.out.println("object = " + decoder.readObject());
    decoder.close();
}
 
源代码13 项目: hottub   文件: Test6329581.java

private Object decode(byte[] array) {
    ByteArrayInputStream in = new ByteArrayInputStream(array);
    XMLDecoder decoder = new XMLDecoder(in, null, this, this);
    Object object = decoder.readObject();
    validate(object);
    decoder.close();
    return object;
}
 
源代码14 项目: openjdk-jdk9   文件: AbstractTest.java

private Object readObject(byte[] array) {
    ByteArrayInputStream input = new ByteArrayInputStream(array);
    XMLDecoder decoder = new XMLDecoder(input);
    decoder.setExceptionListener(this);
    initialize(decoder);
    Object object = decoder.readObject();
    decoder.close();
    return object;
}
 
源代码15 项目: jdk8u-jdk   文件: Test4676532.java

public static void main(String[] args) throws Exception {
    StringBuilder sb = new StringBuilder(256);
    sb.append("file:");
    sb.append(System.getProperty("test.src", "."));
    sb.append(File.separatorChar);
    sb.append("test.jar");

    URL[] url = {new URL(sb.toString())};
    URLClassLoader cl = new URLClassLoader(url);

    Class type = cl.loadClass("test.Test");
    if (type == null) {
        throw new Error("could not find class test.Test");
    }


    InputStream stream = new ByteArrayInputStream(DATA.getBytes());

    ExceptionListener el = new ExceptionListener() {
        public void exceptionThrown(Exception exception) {
            throw new Error("unexpected exception", exception);
        }
    };

    XMLDecoder decoder = new XMLDecoder(stream, null, el, cl);
    Object object = decoder.readObject();
    decoder.close();

    if (!type.equals(object.getClass())) {
        throw new Error("unexpected " + object.getClass());
    }
}
 
源代码16 项目: jdk8u60   文件: Test6341798.java

private static void test(Locale locale, byte[] data) {
    Locale.setDefault(locale);
    System.out.println("locale = " + locale);

    XMLDecoder decoder = new XMLDecoder(new ByteArrayInputStream(data));
    System.out.println("object = " + decoder.readObject());
    decoder.close();
}
 
源代码17 项目: openjdk-jdk8u   文件: Test4676532.java

public static void main(String[] args) throws Exception {
    StringBuilder sb = new StringBuilder(256);
    sb.append("file:");
    sb.append(System.getProperty("test.src", "."));
    sb.append(File.separatorChar);
    sb.append("test.jar");

    URL[] url = {new URL(sb.toString())};
    URLClassLoader cl = new URLClassLoader(url);

    Class type = cl.loadClass("test.Test");
    if (type == null) {
        throw new Error("could not find class test.Test");
    }


    InputStream stream = new ByteArrayInputStream(DATA.getBytes());

    ExceptionListener el = new ExceptionListener() {
        public void exceptionThrown(Exception exception) {
            throw new Error("unexpected exception", exception);
        }
    };

    XMLDecoder decoder = new XMLDecoder(stream, null, el, cl);
    Object object = decoder.readObject();
    decoder.close();

    if (!type.equals(object.getClass())) {
        throw new Error("unexpected " + object.getClass());
    }
}
 
源代码18 项目: openjdk-jdk9   文件: Test4822050.java

private void parse() {
    XMLDecoder decoder = new XMLDecoder(new ByteArrayInputStream(this.buffer));
    decoder.readObject();
    decoder.close();
}
 
源代码19 项目: dragonwell8_jdk   文件: Test4822050.java

private void parse() {
    XMLDecoder decoder = new XMLDecoder(new ByteArrayInputStream(this.buffer));
    decoder.readObject();
    decoder.close();
}
 
源代码20 项目: jdk8u-jdk   文件: Test4822050.java

private void parse() {
    XMLDecoder decoder = new XMLDecoder(new ByteArrayInputStream(this.buffer));
    decoder.readObject();
    decoder.close();
}