Word Counter program in Java