SHARE
TWEET

8taskCorrected

a guest Dec 5th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.         String fileName;
  25.         if (args.length==1) {
  26.                 System.out.print("Print file name to save: ");
  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) {
  35.             if (!args[1].endsWith(".txt")) {
  36.                 args[1] += ".txt";
  37.             }
  38.             ArrayUtils.writeArrayToFile(args[1], (arr2));}
  39.         else System.err.print(-1);
  40.         }
  41.     }
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top