code: private static int getBlockLength(String text, int offset)
     {
        int startIndex = offset;
        boolean finished = false;
        char c;
  
        while (finished == false)
        {
           c = text.charAt(offset);
           switch (c)
           {
              case '\r':
              case '\n':
              case '}':
              {
                 finished = true;
                 break;
              }
  
              default:
              {
                 ++offset;
                 break;
              }
           }
        }
  
        int length = offset - startIndex;
  
        return (length);
     }
docs: Calculates the length of the next block of RTF data.
  
  @param text RTF data
  @param offset current offset into this data
  @return block length