This is somehow a duplicate of this problem Ruby - replace the first occurrence of a substring with another string just in java.
Problem is:
I have a string:
Try using replaceFirst() (available since Java 1.4), it does just what you need:
string = string.replaceFirst("ha", "gurp");