code: public static List<ContentRange> parseFromHeader(String rawRange, 
      long totalSize,
      int maxNum) throws InvalidRangeException
    {
      List<ContentRange> result = new ArrayList<>();
      if (rawRange != null)
      {
        if(!fullPattern.matcher(rawRange).matches())
        {
          throw new InvalidRangeException("invalid syntax");
        }
        
        rawRange = rawRange.substring("bytes=".length(), rawRange.length());
        
        
        for(String partRange : Splitter.on(",")
          .omitEmptyStrings().trimResults().split(rawRange))
        {
          if(result.size() >= totalSize)
          {
            throw new InvalidRangeException("more ranges than acceptable");
          }
          
          long from = 0;
          long to = totalSize-1;
          
          Matcher m = partPattern.matcher(partRange);
          if(!m.find())
          {
            throw new InvalidRangeException("invalid syntax for partial range");
          }
          
          String fromString = m.group(1);
          String toString = m.group(2);
          
          if(fromString != null && !fromString.isEmpty())
          {
            from = Long.parseLong(fromString);
          }
          if(toString != null && !toString.isEmpty())
          {
            to = Long.parseLong(toString);
          }
          
          if(from > to)
          {
            throw new InvalidRangeException("start is larger then end");
          }
          
          result.add(new ContentRange(from, to, totalSize));
          
        }
      }
      return result;
    }
docs: Parses the header value of a HTTP Range request
  @param rawRange raw range value as given by the header
  @param totalSize total size of the content
  @param maxNum maximal number of allowed ranges. Will throw exception if client requests more ranges.
  @return
  @throws annis.gui.requesthandler.ContentRange.InvalidRangeException