[Solved] Java / Javascript : File Comparison line by line while ignoring certain section


java.lang.StringIndexOutOfBoundsException comes from this code:

for (int i = 0; i < strLine1.length(); i++) {
   if (strLine1.charAt(i) != strLine2.charAt(i)) {
       System.out.println("char not same at " + i);
   }   
}

When you scroll larger String strLine to an index, that is greater than the length of strLine2 (second file is smaller than the first) you get that exception. It comes, because strLine2 does not have values on those indexes when it is shorter.

1

solved Java / Javascript : File Comparison line by line while ignoring certain section