Java DataOutputStream Write Object writeObjectToStream(Object obj, DataOutputStream data)

Here you can find the source of writeObjectToStream(Object obj, DataOutputStream data)

Description

write Object To Stream

License

Apache License

Declaration

private static void writeObjectToStream(Object obj, DataOutputStream data) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.DataOutputStream;
import java.io.IOException;

public class Main {
    private static void writeObjectToStream(Object obj, DataOutputStream data) throws IOException {
        Class objClass = obj.getClass();

        //TODO: Add more as needed. Currently not.
        if (objClass.equals(Integer.class)) {
            data.writeInt((Integer) obj);
        } else if (objClass.equals(String.class)) {
            data.writeUTF((String) obj);
        }//from  w w  w . ja v a 2 s  .  c o  m
    }
}

Related

  1. writeObject(DataOutputStream dos, Object o)
  2. writeObject(final DataOutputStream out, final Serializable object)
  3. writeObjectToStream(Object obj, DataOutputStream data)