title: Java string comparison
body: <p>I am comparing substrings in two large text files. Very simple,  tokenizing into two token containers, comparing with 2 for loops. <strong>Performance is disastrous!</strong> Does anybody have an advice or idea how to improve performance?</p>
  
  <pre><code>for (int s = 0; s &lt; txtA.TokenContainer.size(); s++) {
      String strTxtA = txtA.getSubStr(s);
      strLengthA = txtA.getNumToken(s);
  
      if (strLengthA &gt;= dp.getMinStrLength()) {
          int tokenFileB = 1;
  
          for (int t = 0; t &lt; txtB.TokenContainer.size(); t++) {
              String strTxtB = txtB.getSubStr(t);
              strLengthB = txtB.getNumToken(t);
  
              if (strTxtA.equalsIgnoreCase(strTxtB)) {
                  try {
                      subStrTemp = new SubStrTemp(
                          txtA.ID, txtB.ID, tokenFileA, tokenFileB,
                          (tokenFileA + strLengthA - 1), 
                          (tokenFileB + strLengthB - 1));
  
                      if (subStrContainer.contains(subStrTemp) == false) {
                          subStrContainer.addElement(subStrTemp);
                      }
                  } catch (Exception ex) {
                      logger.error("error");
                  }
              }
              tokenFileB += strLengthB;
          }
          tokenFileA += strLengthA;
      }
  }
  </code></pre>
  
  <p>Generally my code reading two large Strings with Java Tokonizer into containers A and B. And then trying to compare substrings.Possision of Substrgs which are existing in both strings to store into a Vector. But performance is awful, also don't really know how to solve it with HashMap.</p>