Advertisement
Guest User

8 task

a guest
Dec 5th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.32 KB | None | 0 0
  1. package com.company;
  2.  
  3. import com.company.ArrayUtils;
  4. import com.company.SwingUtils;
  5. import java.util.Locale;
  6. import java.util.Scanner;
  7.  
  8.  
  9. public class Program {
  10.  
  11.     public static void main(String[] args) throws Exception {
  12.         //SwingUtils.setLookAndFeelByName("Windows");
  13.         if (args.length == 0) {
  14.             Locale.setDefault(Locale.ROOT);
  15.             //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  16.             SwingUtils.setDefaultFont("Times New Roman", 16);
  17.  
  18.             /* Create and display the form */
  19.             java.awt.EventQueue.invokeLater(() -> new FrameMain().setVisible(true));
  20.         }
  21.         else  {int[][] matrix = ArrayUtils.readIntArray2FromFile(args[0]);
  22.         String[][] arr2;
  23.         arr2 = Task.solution(matrix);
  24.         if (args.length==1) {
  25.                 System.out.print("Print file name to save: ");
  26.                 String fileName;
  27.                 Scanner scn = new Scanner(System.in);
  28.                 fileName = scn.nextLine();
  29.             if (!fileName.toLowerCase().endsWith(".txt")) {
  30.                 fileName += ".txt";
  31.             }
  32.                 ArrayUtils.writeArrayToFile(fileName, arr2);
  33.             }
  34.         if (args.length == 2) ArrayUtils.writeArrayToFile(args[1], (arr2));
  35.         else System.err.print(-1);
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement