title: How to read values and assign variables to them from text file using scanner?
body: <p>This is my text file "demo.txt". I have to read value value and assign variables like rule for Success, object for product...</p>
  
  <pre><code>import java.io.*;
  import java.util.*;
  public class Read {
      public static void main(String[] args) throws Exception {
          File file=new File("demo.txt");
          Scanner s=new Scanner(file);
          while(s.hasNextLine()) {
              String rule=s.next();
              System.out.println(rule);
          }
      }
  } 
  </code></pre>
  
  <p>Here if just want the rule Success to be printed what to do then:</p>
  
  <blockquote>
    <p>Success<br>
    product</p>
  </blockquote>
  
  <p>If the price of the product is greater than 100 and quantity less than 2 and category is "grocery" then<br>
     print the discount equal to 100<br>
  Then display the discount is 100 </p>