code: public static void fieldsToString (
              StringBuilder buf, Object object, String sep)
      {
          Class<?> clazz = object.getClass();
          Field[] fields = clazz.getFields();
          int written = 0;
  
          // we only want non-static fields
          for (Field field : fields) {
              int mods = field.getModifiers();
              if ((mods & Modifier.PUBLIC) == 0 || (mods & Modifier.STATIC) != 0) {
                  continue;
              }
  
              if (written > 0) {
                  buf.append(sep);
              }
  
              // look for a toString() method for this field
              buf.append(field.getName()).append("=");
              try {
                  try {
                      Method meth = clazz.getMethod(field.getName() + "ToString", new Class<?>[0]);
                      buf.append(meth.invoke(object, (Object[]) null));
                  } catch (NoSuchMethodException nsme) {
                      toString(buf, field.get(object));
                  }
              } catch (Exception e) {
                  buf.append("<error: " + e + ">");
              }
              written++;
          }
      }
docs: Like {@link #fieldsToString(StringBuilder,Object)} except that the supplied separator will
  be used between fields.