Write a while loop that replaces every occurrence of "cat" in the message with "dog" using the indexOf and substring methods.

String message = "I love cats! I have a cat named Coco. My cat's very smart!";

The answer should be in Java!