Here you can find the source of writeObjectToStream(Object obj, DataOutputStream data)
private static void writeObjectToStream(Object obj, DataOutputStream data) throws IOException
//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 } }