public static void writeString(DataOutputStream os,String s) throws IOException {
  if (s == null) {
    os.writeInt(-1);
  }
 else {
    byte array[]=s.getBytes();
    os.writeInt(array.length);
    os.write(array);
  }
}

public static void writeString ( DataOutputStream os , String s ) throws IOException { if ( s == null ) { os . writeInt ( - 1 ) ; } else { byte array [ ] = s . getBytes ( ) ; os . writeInt ( array . length ) ; os . write ( array ) ; } }
write string to dataoutputstream motivation : datainputstream . readutf can ' t print lines larger than ushortmax
