In programming, tokenizing a String is a simple way of achieving lexical analysis. It is a simple way of producing parts of a String that we can process one by one. We achieve this in Java using the StringTokenizer class. Groovy has made it more convenient by providing the tokenize() method in the String class. Below are some examples on how to use tokenization of String in Groovy.