Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main;
- import java.io.File;
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.text.DateFormat;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.time.DayOfWeek;
- import java.util.Calendar;
- import java.util.Date;
- import javafx.application.Application;
- import javafx.scene.Scene;
- import javafx.scene.control.Button;
- import javafx.scene.control.Label;
- import javafx.scene.layout.BorderPane;
- import javafx.scene.layout.GridPane;
- import javafx.stage.Stage;
- import podaci.SyncPipe;
- public class Main extends Application
- {
- public static void main(String[] args)
- {
- launch(args);
- }
- @Override
- public void start(Stage primaryStage) throws Exception
- {
- GridPane bp = new GridPane();
- Label lbl = new Label("Trenutan datum: ");
- DateFormat fa = new SimpleDateFormat("dd-MM-yyyy");
- Date fu = new Date();
- lbl.setText(lbl.getText() + fa.format(fu));
- Button dugme = new Button("Dugmeeee");
- Button provera = new Button("Provera");
- bp.add(dugme, 0, 0);
- bp.add(lbl, 0, 1);
- bp.add(provera, 0, 2);
- dugme.setOnAction(e->
- {
- DateFormat datum1 = new SimpleDateFormat("dd-MM-yyyy");
- Date date = new Date();
- lbl.setText(lbl.getText() + datum1.format(date));
- Calendar kalendar = Calendar.getInstance();
- String[] command =
- {
- "cmd",
- };
- Process p;
- try
- {
- p = Runtime.getRuntime().exec(command);
- new Thread(new SyncPipe(p.getErrorStream(), System.err)).start();
- new Thread(new SyncPipe(p.getInputStream(), System.out)).start();
- PrintWriter stdin = new PrintWriter(p.getOutputStream());
- //-----------------------------LEKOVI------------------------------------//
- for(int i = 0; i < 30; i++)
- {
- int dan = kalendar.get(Calendar.DAY_OF_MONTH);
- int mesec = kalendar.get(Calendar.MONTH);
- int godina = kalendar.get(Calendar.YEAR);
- if(dan<10 && mesec<10)
- {
- stdin.println("wget -r --output-document=file.zip --http-user= --http-password= "
- + "http://.zip");
- }
- else
- {
- if(dan<10)
- {
- stdin.println("wget -r --output-document=file.zip --http-user= --http-password= "
- + "http://.zip");
- }
- else if(mesec<10)
- {
- stdin.println("wget -r --output-document=file.zip --http-user= --http-password= "
- + "http://.zip");
- }
- else
- {
- stdin.println("wget -r --output-document=file.zip --http-user= --http-password= "
- + "http://.zip");
- }
- }
- stdin.println("7za e file.zip");
- if(dan<10 && mesec<10)
- {
- File tmpDir = new File("file.zip");
- System.out.println(tmpDir.getAbsolutePath());
- if(tmpDir.exists())
- break;
- }
- else
- {
- if(dan<10)
- {
- File tmpDir = new File("file.zip");
- if(tmpDir.exists())
- break;
- }
- else if(mesec<10)
- {
- File tmpDir = new File("file.zip");
- if(tmpDir.exists())
- break;
- }
- else
- {
- File tmpDir = new File("file.zip");
- if(tmpDir.exists())
- break;
- }
- }
- kalendar.add(Calendar.DATE, -1);
- }
- kalendar = Calendar.getInstance();
- stdin.close();
- int returnCode = p.waitFor();
- System.out.println("Return code = " + returnCode);
- } catch (IOException e1)
- {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- } catch (InterruptedException e1)
- {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- });
- Scene sc = new Scene(bp, 600,400);
- primaryStage.setScene(sc);
- primaryStage.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement