code: private String trim(String line) {
          char[] chars = line.toCharArray();
          int len = chars.length;
  
          while (len > 0) {
              if (!Character.isWhitespace(chars[len - 1])) {
                  break;
              }
              len--;
          }
  
          return line.substring(0, len);
      }
docs: Trim the trailing spaces.
  
  @param line