University stuff.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import java.io.File;
  2. import java.io.OutputStream;
  3. import java.io.FileOutputStream;
  4. class Cli {
  5. public static void main(String[] args) throws Exception {
  6. if (args.length < 1) {
  7. System.out.println("Usage: java Cli <input> [output]");
  8. return;
  9. }
  10. File in = new File(args[0]);
  11. OutputStream out;
  12. if (args.length > 1) {
  13. File f = new File(args[1]);
  14. f.createNewFile();
  15. out = new FileOutputStream(f);
  16. System.out.println(args[1]);
  17. } else {
  18. out = System.out;
  19. }
  20. Brett b;
  21. try {
  22. b = new Brett(in);
  23. } catch (Exception ex) {
  24. System.out.println(ex.toString());
  25. System.exit(1);
  26. return;
  27. }
  28. b.print();
  29. SudokuBeholder sb = b.los();
  30. System.out.println("");
  31. System.out.println("Fant "+sb.hentAntallLosninger()+" losninger.");
  32. if (args.length > 1) {
  33. System.out.println("Skriver til filen "+args[1]);
  34. }
  35. for (SudokuBeholder.Losning l: sb) {
  36. sb.print(out, l);
  37. out.write("\n".getBytes());
  38. }
  39. out.flush();
  40. }
  41. }