Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.88 KB | None | 0 0
  1. package main;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.io.PrintWriter;
  6. import java.text.DateFormat;
  7. import java.text.ParseException;
  8. import java.text.SimpleDateFormat;
  9. import java.time.DayOfWeek;
  10. import java.util.Calendar;
  11. import java.util.Date;
  12.  
  13. import javafx.application.Application;
  14. import javafx.scene.Scene;
  15. import javafx.scene.control.Button;
  16. import javafx.scene.control.Label;
  17. import javafx.scene.layout.BorderPane;
  18. import javafx.scene.layout.GridPane;
  19. import javafx.stage.Stage;
  20. import podaci.SyncPipe;
  21.  
  22. public class Main extends Application
  23. {
  24.  
  25.     public static void main(String[] args)
  26.     {
  27.         launch(args);
  28.  
  29.     }
  30.  
  31.     @Override
  32.     public void start(Stage primaryStage) throws Exception
  33.     {
  34.         GridPane bp = new GridPane();
  35.         Label lbl = new Label("Trenutan datum: ");
  36.         DateFormat fa = new SimpleDateFormat("dd-MM-yyyy");
  37.         Date fu = new Date();
  38.         lbl.setText(lbl.getText() + fa.format(fu));
  39.         Button dugme = new Button("Dugmeeee");
  40.         Button provera = new Button("Provera");
  41.         bp.add(dugme, 0, 0);
  42.         bp.add(lbl, 0, 1);
  43.         bp.add(provera, 0, 2);
  44.         dugme.setOnAction(e->
  45.         {
  46.             DateFormat datum1 = new SimpleDateFormat("dd-MM-yyyy");
  47.             Date date = new Date();
  48.             lbl.setText(lbl.getText() + datum1.format(date));
  49.             Calendar kalendar = Calendar.getInstance();
  50.             String[] command =
  51.                 {
  52.                     "cmd",
  53.                 };
  54.                 Process p;
  55.                 try
  56.                 {
  57.                     p = Runtime.getRuntime().exec(command);
  58.  
  59.                 new Thread(new SyncPipe(p.getErrorStream(), System.err)).start();
  60.                 new Thread(new SyncPipe(p.getInputStream(), System.out)).start();
  61.  
  62.                 PrintWriter stdin = new PrintWriter(p.getOutputStream());
  63.  
  64.               //-----------------------------LEKOVI------------------------------------//
  65.                 for(int i = 0; i < 30; i++)
  66.                 {
  67.                     int dan = kalendar.get(Calendar.DAY_OF_MONTH);
  68.                     int mesec = kalendar.get(Calendar.MONTH);
  69.                     int godina = kalendar.get(Calendar.YEAR);
  70.  
  71.                     if(dan<10 && mesec<10)
  72.                     {
  73.                         stdin.println("wget -r --output-document=file.zip --http-user= --http-password= "
  74.                                 + "http://.zip");
  75.                     }
  76.                     else
  77.                     {
  78.                         if(dan<10)
  79.                         {
  80.                             stdin.println("wget -r --output-document=file.zip --http-user= --http-password= "
  81.                                     + "http://.zip");
  82.                         }
  83.                         else if(mesec<10)
  84.                         {
  85.                             stdin.println("wget -r --output-document=file.zip --http-user= --http-password= "
  86.                                     + "http://.zip");
  87.                         }
  88.                         else
  89.                         {
  90.                             stdin.println("wget -r --output-document=file.zip --http-user= --http-password= "
  91.                                     + "http://.zip");
  92.                         }
  93.                     }
  94.                     stdin.println("7za e file.zip");
  95.  
  96.                     if(dan<10 && mesec<10)
  97.                     {
  98.                         File tmpDir = new File("file.zip");
  99.                         System.out.println(tmpDir.getAbsolutePath());
  100.                         if(tmpDir.exists())
  101.                             break;
  102.                     }
  103.                     else
  104.                     {
  105.                         if(dan<10)
  106.                         {
  107.                             File tmpDir = new File("file.zip");
  108.                             if(tmpDir.exists())
  109.                                 break;
  110.                         }
  111.                         else if(mesec<10)
  112.                         {
  113.                             File tmpDir = new File("file.zip");
  114.                             if(tmpDir.exists())
  115.                                 break;
  116.                         }
  117.                         else
  118.                         {
  119.                             File tmpDir = new File("file.zip");
  120.                             if(tmpDir.exists())
  121.                                 break;
  122.                         }
  123.                     }
  124.                     kalendar.add(Calendar.DATE, -1);
  125.  
  126.                 }
  127.  
  128.                 kalendar = Calendar.getInstance();
  129.                 stdin.close();
  130.                 int returnCode = p.waitFor();
  131.                 System.out.println("Return code = " + returnCode);
  132.                 } catch (IOException e1)
  133.                 {
  134.                     // TODO Auto-generated catch block
  135.                     e1.printStackTrace();
  136.                 } catch (InterruptedException e1)
  137.                 {
  138.                     // TODO Auto-generated catch block
  139.                     e1.printStackTrace();
  140.                 }
  141.  
  142.         });
  143.        
  144.         Scene sc = new Scene(bp, 600,400);
  145.         primaryStage.setScene(sc);
  146.         primaryStage.show();
  147.     }
  148.  
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement