public float write ( ) throws IOException { bitArray . setAll ( false ) ; for ( int ii = 0 ; ii < bytes ; ii ++ ) { bitArray . set ( ii , bb1 . get ( ii ) != bb2 . get ( ii ) ) ; } if ( ! bitArray . any ( ) ) { return 0 ; } if ( ! bitArray . and ( selfImportantArray ) ) { return 0 ; } if ( writeCount == 0 ) { DataOutputStream dos = new DataOutputStream ( out ) ; dos . writeUTF ( source ) ; dos . writeShort ( properties . size ( ) ) ; List < Property > props = new ArrayList <> ( properties . values ( ) ) ; props . sort ( null ) ; for ( Property prop : props ) { dos . writeUTF ( prop . getName ( ) ) ; dos . writeUTF ( prop . getType ( ) ) ; } dos . writeLong ( uuid . getMostSignificantBits ( ) ) ; dos . writeLong ( uuid . getLeastSignificantBits ( ) ) ; } out . write ( bits ) ; int cnt = 0 ; for ( int ii = 0 ; ii < bytes ; ii ++ ) { if ( bitArray . isSet ( ii ) ) { byte b = bb2 . get ( ii ) ; out . write ( b ) ; bb1 . put ( ii , b ) ; cnt ++ ; writeBytes ++ ; } } writeCount ++ ; return ( float ) cnt / ( float ) bytes ; }
Writes objects fields to stream