Browse Source

Ajout lecture fichier configuration

EyeXion 7 months ago
parent
commit
957a30a0d9

+ 1
- 0
93afae596379672a/identity.public View File

@@ -0,0 +1 @@
1
+6dd56cfbc8:0:0fefc967b5f66ad50a193eb20616df573733c8d4c86673cdadafddc689831d4528b539702674056bd76afecd4f30b1a33b9b930637a65230b02c91c9c310ccdb

BIN
93afae596379672a/planet View File


BIN
build/libs/Clavardage-1.0-all.jar View File


+ 51
- 10
src/main/java/app/insa/clav/Main.java View File

@@ -7,21 +7,62 @@ import javafx.scene.Parent;
7 7
 import javafx.scene.Scene;
8 8
 import javafx.stage.Stage;
9 9
 
10
+import java.io.FileInputStream;
11
+import java.io.IOException;
12
+import java.util.Properties;
13
+
10 14
 public class Main extends Application{
11 15
 
12 16
 
13 17
     @Override
14 18
     public void start(Stage primaryStage) throws Exception{
15
-        String[] args = this.getParameters().getUnnamed().toArray(new String[0]);
16
-        String addrBroad = args[0];
17
-        int udpListeningPort = Integer.parseInt(args[1]);
18
-        String urlServeur = args[2];
19
-        String addrBdd = args[3];
20
-        String userBdd = args[4];
21
-        String mdpBdd = args[5];
22
-        String nomBdd = args[6];
23
-
24
-        Model model = Model.getInstance(addrBroad, udpListeningPort, this, addrBdd, userBdd, mdpBdd, nomBdd, urlServeur);
19
+        String addrBroad;
20
+        int udpListeningPort;
21
+        String urlServeur;
22
+        String addrBdd;
23
+        String userBdd;
24
+        String mdpBdd;
25
+        String nomBdd;
26
+
27
+        try {
28
+            //to load application's properties, we use this class
29
+            Properties mainProperties = new Properties();
30
+
31
+            FileInputStream file;
32
+
33
+            //the base folder is ./, the root of the main.properties file
34
+            String path = "./config.properties";
35
+
36
+            //load the file handle for main.properties
37
+            file = new FileInputStream(path);
38
+
39
+            //load all the properties from this file
40
+            mainProperties.load(file);
41
+
42
+            //we have loaded the properties, so close the file handle
43
+            file.close();
44
+
45
+
46
+            System.out.println(mainProperties.getProperty("app.localNetIPAddress"));
47
+            System.out.println(mainProperties.getProperty("app.udpPortNumber"));
48
+            System.out.println(mainProperties.getProperty("app.servletURL"));
49
+            System.out.println(mainProperties.getProperty("app.dataBaseAddress"));
50
+            System.out.println(mainProperties.getProperty("app.dataBaseUser"));
51
+            System.out.println(mainProperties.getProperty("app.dataBasePasswd"));
52
+            System.out.println(mainProperties.getProperty("app.dataBaseName"));
53
+
54
+            addrBroad = mainProperties.getProperty("app.localNetIPAddress");
55
+            udpListeningPort = Integer.parseInt(mainProperties.getProperty("app.udpPortNumber"));
56
+            urlServeur = mainProperties.getProperty("app.servletURL");
57
+            addrBdd = mainProperties.getProperty("app.dataBaseAddress");
58
+            userBdd = mainProperties.getProperty("app.dataBaseUser");
59
+            mdpBdd = mainProperties.getProperty("app.dataBasePasswd");
60
+            nomBdd = mainProperties.getProperty("app.dataBaseName");
61
+            Model model = Model.getInstance(addrBroad, udpListeningPort, this, addrBdd, userBdd, mdpBdd, nomBdd, urlServeur);
62
+        } catch (IOException e) {
63
+            e.printStackTrace();
64
+        }
65
+
25 66
 
26 67
         FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/splashScreen.fxml"));
27 68
         Parent root =fxmlLoader.load();

Loading…
Cancel
Save