title: Compare line by line from a text file in Java
body: <p>I am trying to compare lines from a text file in Java.
  For example, there is a text file with these lines:</p>
  
  <blockquote>
    <p>temp1 am 32.5 pm 33.5<br> temp2 am 33.5 pm 33.5<br> temp3 am 32.5 pm
    33.5<br> temp4 am 31.5 pm 35</p>
  </blockquote>
  
  <p><strong>a b c d e<br><br></strong></p>
  
  <p><strong><em>a</em></strong> is the name of the line, <strong><em>b</em></strong> is constant(am), <strong><em>c</em></strong> is a variable, <strong><em>d</em></strong> is constant(pm), <strong><em>e</em></strong> is another variable.</p>
  
  <p>It will only compare the variables -> temp1(c) to temp2(c), temp1(e) to temp2(e) etc.</p>
  
  <p>When there are two or more lines with the same c(s) and e(s), it will throw FormatException.</p>
  
  <p>From the example text file above, because temp1's c is the same as temp3's c and temps1's e is the same as temp3's e, it will throw FormatException.</p>
  
  <p>This is what I have so far:<br></p>
  
  <pre><code>public static Temp read(String file) throws FormatException {
          String line = "";
          FileReader fr = new FileReader(fileName);
          Scanner scanner = new Scanner(fr);
  
          while(scanner.hasNextLine()) {
              String line = scanner.nextLine();
              System.out.println(line);
          }
          scanner.close();
  
          if () {
              throw new FormatException("Error.");
  </code></pre>
  
  <p>How can I make this?</p>