Here you can find the source of findCommonPrefixLength(CharSequence str1, CharSequence str2)
private static int findCommonPrefixLength(CharSequence str1, CharSequence str2)
//package com.java2s; public class Main { private static int findCommonPrefixLength(CharSequence str1, CharSequence str2) {/*from w ww. j a v a2s.c o m*/ int length = (Math.min(str1.length(), str2.length())); for (int i = 0; i < length; i++) { if (str1.charAt(i) != str2.charAt(i)) { return i; } } return 0; } }