123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import java.io.File;
- import java.io.OutputStream;
- import java.io.FileOutputStream;
-
- class Cli {
- public static void main(String[] args) throws Exception {
- if (args.length < 1) {
- System.out.println("Usage: java Cli <input> [output]");
- return;
- }
-
- File in = new File(args[0]);
- OutputStream out;
-
- if (args.length > 1) {
- File f = new File(args[1]);
- f.createNewFile();
- out = new FileOutputStream(f);
- System.out.println(args[1]);
- } else {
- out = System.out;
- }
-
- Brett b;
- try {
- b = new Brett(in);
- } catch (Exception ex) {
- System.out.println(ex.toString());
- System.exit(1);
- return;
- }
- b.print();
-
- SudokuBeholder sb = b.los();
- System.out.println("");
- System.out.println("Fant "+sb.hentAntallLosninger()+" losninger.");
-
- if (args.length > 1) {
- System.out.println("Skriver til filen "+args[1]);
- }
-
- for (SudokuBeholder.Losning l: sb) {
- sb.print(out, l);
- out.write("\n".getBytes());
- }
- out.flush();
- }
- }
|