Compare two text files string by string in java
<p>I have two text files and I want to compare the contents of text files using java. </p>

<p>For example  First file <strong>e1.txt</strong> has the content <code>"hello this is india"</code> , and another <strong>e2.txt</strong> contents <code>"hello this is usa"</code>. I want the output should be the text which is not similer in both files(here output should be india or usa). </p>

<p>Problem which I was facing here is that java IO method reads line by line so in this case no output will be given(both lines are different), also white spaces should be ignored. 
I will be very much thankful if anyone will help me in this problem.</p>

<p>Here is my Code :</p>

<pre><code> public void fh() throws FileNotFoundException, IOException{
    File f1=new File("C:\\\\Users\\\\Ramveer\\\\Desktop\\\\idrbt Project\\\\e1.txt");
    File f2=new File("C:\\\\Users\\\\Ramveer\\\\Desktop\\\\idrbt Project\\\\e2.txt");
    FileInputStream fi1=new FileInputStream(f1);
    FileInputStream fi2=new FileInputStream(f2); 
    DataInputStream di1=new DataInputStream(fi1);
    BufferedReader br1=new BufferedReader(new InputStreamReader(di1));
    DataInputStream di2=new DataInputStream(fi2);
    BufferedReader br2=new BufferedReader(new InputStreamReader(di2));
    String s1, s2;  
    while ((s1=br1.readLine())!=null &amp;&amp; (s2=br2.toString())!=null) 
     {
    if(!s1.equals(s2)){
    System.out.println(s1);
      }
    } 
}
</code></pre>
