Files
SAE32_2022/src/Graphics/GraphicFile.java

43 lines
1.1 KiB
Java
Raw Normal View History

2023-01-05 03:22:24 +01:00
package Graphics;
import java.io.InputStream;
import java.io.IOException;
2023-01-05 05:56:05 +01:00
import java.util.HashMap;
2023-01-05 03:22:24 +01:00
import javax.swing.JPanel;
import java.awt.GridLayout;
import java.net.URL;
2023-01-05 05:56:05 +01:00
/**
* [Romain]
* Pour gerer l'affichage graphique du code JSON
*/
2023-01-05 03:22:24 +01:00
public class GraphicFile extends JPanel {
2023-01-05 05:56:05 +01:00
/**
* @param url Le chemin vers le fichier JSON
*/
2023-01-05 03:22:24 +01:00
public GraphicFile(URL url) {
super();
try {
System.out.println("[+] Lecture de " + url);
this.setLayout(new GridLayout(100, 1));
InputStream jsonReader = url.openStream();
2023-01-05 05:56:05 +01:00
/**
* C'est ici que le hashmap est stocke
*/
Traitable fileTraited = new Traitable(jsonReader);
HashMap<String, Object> allVariables = fileTraited.getVariableMap();
2023-01-05 03:22:24 +01:00
2023-01-05 18:34:55 +01:00
for (String key : allVariables.keySet()) {
System.out.println("Clé : " + key + " , Valeur : " + allVariables.get(key));
}
2023-01-05 03:22:24 +01:00
jsonReader.close();
} catch (IOException e) {
System.out.println("[!] Fichier " + url.getFile() + " n'existe pas");
}
}
}