title: Counting { and } braces in program JAVA
body: <p>I have to read an input file that contains codes and produce an output that matches the corresponding braces ({ and })</p>
  
  <p>example of how output will look</p>
  
  <pre><code>import java.util.scanner;
  public class Tester {1
   public static void main(String[] args) {2
   Scanner in = new Scanner (System.in);
   int price = in.nextInt;
   if (price &lt; 10)
   System.out.println("Good price");
   System.out.println ("Buy it");
   }2
   }1
   }0
  }0
  </code></pre>
  
  <p>0 will represent extra braces that has no matches.
  What is the most efficient way to approach this?
  Should I just process line by line with Strings? </p>