Java Discovery: String.split
In my first year at Ryerson I had to do a java programming assignment where the point was to take a fairly long string, tokenize it, and then do something with each of the words (I can’t remember what we had to do). The real point of the exercise was to get us used to reading input from the command line and using the String Tokenizer.
Today, I had to create a class that split a string a comma separated string. This is very similar to the assingment describe above. So I went to the javadoc for StringTokenizer and read that it was deprecated and the you should use the split method in the String class.
So I went over to the javadoc for the String class. Sure enough, there is a beautiful little method called split. What split does is it splits a string using whatever token you pass it as the delimiter and returns an array of Strings.
Personally, I think this is pretty cool. I have got to read through the javadocs more often and find out what all is hidden within the Java language.