title: To find similar words (strings) in two files
body: <p>I have to validate the similarity of word 1 in file 1 with word 2 in file 2 and so on. if word 1 (file 1).equals to word 2 (file 2), file 3 will be the output to show the True and False. Below is the coding but I am stuck when there is no error but giving no output. Am a beginner in JAVA.</p>
  
  <pre><code>import java.io.File;
  import java.io.FileNotFoundException;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.Scanner;
  
  public class test2 {
  
      private static ArrayList&lt;String&gt; load(String f1) throws FileNotFoundException {
          Scanner reader = new Scanner(new File(f1));
          ArrayList&lt;String&gt; out = new ArrayList&lt;String&gt;();
          while (reader.hasNext()) {
              String temp = reader.nextLine();
              String[] sts = temp.split(" ");
              for (int i = 0; i &lt; sts.length; i++) {
                  if (sts[i].equals("") &amp;&amp; sts[i].equals(" ") &amp;&amp; sts[i].equals("\n")) {
                      out.add(sts[i]);
                  }
              }
          }
          return out;
      }
  
      private static void write(ArrayList&lt;String&gt; out, String fname) throws IOException {
          FileWriter writer = new FileWriter(new File("out_test2.txt"));
          for (int i = 0; i &lt; out.size(); i++) {
              writer.write(out.get(i) + "\n");
          }
          writer.close();
      }
  
      public static void main(String[] args) throws IOException {
          ArrayList&lt;String&gt; file1;
          ArrayList&lt;String&gt; file2;
          ArrayList&lt;String&gt; out = new ArrayList&lt;String&gt;();
          file1 = load("IbanDict.txt");
          file2 = load("AFF_outVal.txt");
  
          for (int i = 0; i &lt; file1.size(); i++) {
              String word1 = file1.get(i);
              for (int z = 0; z &lt; file2.size(); z++) {
                  if (word1.equalsIgnoreCase(file2.get(z))) {
                      boolean already = false;
                      for (int q = 0; q &lt; out.size(); q++) {
                          if (out.get(q).equalsIgnoreCase(file1.get(i))) {
                              already = true;
                          }
                      }
                      if (already == false) {
                          out.add(file1.get(i));
                      }
                  }
              }
          }
          write(out, "out_test2.txt");
      }
  
  }
  </code></pre>