code: public static void writeSafeUTF (@Nonnull final DataOutput aDO, @Nullable final String sStr) throws IOException
    {
      ValueEnforcer.notNull (aDO, "DataOutput");
      if (sStr == null)
      {
        // Only write a 0 byte
        // Writing a length of 0 would mean that the differentiation between "null" and
        // empty string would be lost.
        aDO.writeByte (0);
      }
      else
      {
        // Non-null indicator; basically the version of layout how the data was written
        aDO.writeByte (2);
  
        final byte [] aUTF8Bytes = sStr.getBytes (StandardCharsets.UTF_8);
  
        // Write number of bytes
        aDO.writeInt (aUTF8Bytes.length);
        // Write main bytes
        aDO.write (aUTF8Bytes);
  
        // Was added in layout version 2:
        aDO.writeInt (END_OF_STRING_MARKER);
      }
    }
docs: Because {@link DataOutputStream#writeUTF(String)} has a limit of 64KB this
  methods provides a similar solution but simply writing the bytes.
  
  @param aDO
  {@link DataOutput} to write to. May not be <code>null</code>.
  @param sStr
  The string to be written. May be <code>null</code>.
  @throws IOException
  on write error
  @see #readSafeUTF(DataInput)