code: public static String extractClientIpFromXForwardedFor(String xForwardedFor) {
          if (xForwardedFor == null) {
              return null;
          }
          xForwardedFor = xForwardedFor.trim();
          String tokenized[] = xForwardedFor.split(",");
          if (tokenized.length == 0) {
              return null;
          } else {
              return tokenized[0].trim();
          }
      }
docs: Extract the client IP address from an x-forwarded-for header. Returns null if there is no x-forwarded-for header
  
  @param xForwardedFor a <code>String</code> value
  @return a <code>String</code> value