<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">import java.io.*;
import edu.cornell.cs.sam.io.SamTokenizer;
import edu.cornell.cs.cs212.sp2004.part3.IllegalBaliException;

public class BC{
  public static void main(String args[]){
    if(args.length &gt; 2 || args.length &lt; 1){
      System.out.println("Usage: java BC &lt;inputfile&gt; [&lt;outputfile&gt;]");
      System.exit(1);
    }
    try{
      SamTokenizer in = new SamTokenizer(args[0]);
      String outFileName = "";
      if(args.length == 2)
        outFileName = args[1];
      else if(args[0].indexOf(".") &lt; 0)
        outFileName = args[0] + ".sam";
      else
        outFileName = args[0].substring(0, args[0].lastIndexOf(".")) + ".sam";
      BufferedWriter out = new BufferedWriter(new FileWriter(outFileName));
      try{
         out.write((new BaliCompiler()).compile(in));
      }
      catch(IllegalBaliException e){
        System.out.println(e.toString());
      }
      out.close();
    }
    catch(IOException e){
      System.out.println("I/O Error: " + e.getMessage());
      System.exit(0);
    }
  }
}
</pre></body></html>