My 'idiomatic one-liner' for this is:
int count =StringUtils.countMatches("a.b.c.d",".");
Why write it yourself when it's already in commons lang?
Spring Framework's oneliner for this is:
int occurance =StringUtils.countOccurrencesOf("a.b.c.d",".");