code: private byte[] trimBytesArray(byte[] source, int offset, int length) {
          int lengthFromBegin;
          for (lengthFromBegin = offset + length; lengthFromBegin > offset; lengthFromBegin--) {
              if (source[lengthFromBegin - 1] != ' ' && source[lengthFromBegin - 1] != '\0'
                      && source[lengthFromBegin - 1] != '\t') {
                  break;
              }
          }
  
          if (lengthFromBegin - offset != 0) {
              return Arrays.copyOfRange(source, offset, lengthFromBegin);
          } else {
              return null;
          }
      }
docs: The function to remove excess symbols from the end of a bytes array. Excess symbols are line end characters,
  tabulation characters, and spaces, which do not contain useful information.
  
  @param source an array of bytes containing required data.
  @param offset the offset in source of required data.
  @param length the length of required data.
  @return the array of bytes without excess symbols at the end.