Code example for DataOutputStream

Methods: flush, writeDouble, writeUTF

0
        return buffer.toByteArray();
    } 
 
    public static byte[] serializeAddress(Address a) throws IOException {
        final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        final DataOutputStream out = new DataOutputStream(buffer);
 
        /* 
         * longitude 
         * latitude 
         * admin area 
         * sub admin area 
         * locality 
         * thoroughfare 
         * feature name 
         */ 
        final String admin = a.getAdminArea();
        final String subAdmin = a.getSubAdminArea();
        final String locality = a.getLocality();
        final String thoroughfare = a.getThoroughfare();
        final String feature = a.getFeatureName();
 
        out.writeDouble(a.getLongitude());
        out.writeDouble(a.getLatitude());
        out.writeUTF(admin != null ? admin : "");
        out.writeUTF(subAdmin != null ? subAdmin : "");
        out.writeUTF(locality != null ? locality : "");
        out.writeUTF(thoroughfare != null ? thoroughfare : "");
        out.writeUTF(feature != null ? feature : "");
 
        out.flush();
        return buffer.toByteArray();
    } 
 
    public static List<Address> deserializeAddresses(byte[] buffer) {
        if (buffer == null)