code: public static String strip(final String s) {
  
          int first;
          int last;
  
          for (first = 0; first < s.length(); first++) {
              if (!Character.isWhitespace(s.charAt(first))) {
                  break;
              }
          }
  
          for (last = s.length(); last > first; last--) {
              if (!Character.isWhitespace(s.charAt(last - 1))) {
                  break;
              }
          }
  
          return s.substring(first, last);
      }
docs: Removes the trailing and leading whitespaces
  
  @param s
  @return the striped string
  @since 3.0.1