Java Code Examples for java.io.Externalizable#readExternal()

The following examples show how to use java.io.Externalizable#readExternal() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JndiRequestTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
private void externalize(final Externalizable original, final Externalizable copy) throws IOException, ClassNotFoundException {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ObjectOutputStream out = new ObjectOutputStream(baos);

    original.writeExternal(out);
    out.close();

    final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    final ObjectInputStream in = new ObjectInputStream(bais);

    copy.readExternal(in);
}
 
Example 2
Source File: ExternalizableSerializer.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Externalizable read(Kryo kryo, Input input, Class<Externalizable> type) {
    try {
        Externalizable e = kryo.newInstance(type);
        KryoObjectInput koi = new KryoObjectInput(input,kryo);
        e.readExternal(koi);
        return e;
    } catch (IOException | ClassNotFoundException e1) {
        throw new RuntimeException(e1);
    }
}
 
Example 3
Source File: ObjectUtils.java    From incubator-hivemall with Apache License 2.0 4 votes vote down vote up
public static void readObject(@Nonnull final InputStream is, @Nonnull final Externalizable dst)
        throws IOException, ClassNotFoundException {
    ObjectInputStream ois = new ObjectInputStream(is);
    dst.readExternal(ois);
}