Right now my code only separates words by white space, but I also want to separate by '.' and "," too. Here is my current code:
for (String words : input.split("\\s+"))
Learn more about regex since you are using it.