public static void writeStringSet ( DataOutputStream os , Collection < String > set ) throws IOException { if ( set == null ) { os . writeInt ( - 1 ) ; } else { os . writeInt ( set . size ( ) ) ; for ( String s : set ) { writeString ( os , s ) ; } } }
Write a set with proper sizing