72 lines
1.9 KiB
Java
72 lines
1.9 KiB
Java
package baseListesEtudiants;
|
|
|
|
import java.io.BufferedReader;
|
|
import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.io.InputStreamReader;
|
|
import java.nio.file.Paths;
|
|
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JOptionPane;
|
|
|
|
import MEPTL.commandes;
|
|
import cXML.node;
|
|
|
|
/**
|
|
*
|
|
* @author pabr6
|
|
*
|
|
*/
|
|
public class recupeNodeBaseListesEtudiants {
|
|
private boolean Hasliste = false;
|
|
|
|
public recupeNodeBaseListesEtudiants() {
|
|
File file = null;
|
|
String directoryName = Paths.get("").toAbsolutePath().toString();
|
|
|
|
if(commandes.os.contains("Win")) {
|
|
file = new File(directoryName + "\\" + "base_listes_etudiants.xml");
|
|
}else {
|
|
file = new File(directoryName + "/" + "base_listes_etudiants.xml");
|
|
}
|
|
|
|
if(file!=null) {
|
|
BufferedReader br;
|
|
try {
|
|
br = new BufferedReader(
|
|
new InputStreamReader(
|
|
new FileInputStream(file.getAbsoluteFile()), "UTF-8"));
|
|
String line;
|
|
StringBuilder targetString = new StringBuilder();
|
|
while ((line = br.readLine()) != null) {
|
|
targetString.append(line);
|
|
}
|
|
String codeTexte = "<!-- A -->" + targetString.toString().replace("\t","").replace("\r", "").replace("\n", "");
|
|
codeTexte = codeTexte.replaceAll(">/{1,}<", "><");
|
|
node nodRetourne = new node(codeTexte);
|
|
|
|
if(nodRetourne.getNomElt().equals("fichier")) {
|
|
nodRetourne.setNomElt("ListesEtudiants");
|
|
}
|
|
|
|
commandes.listesEtudiants = nodRetourne;
|
|
if(nodRetourne.getNodes().size()>0) Hasliste=true;
|
|
|
|
}catch (Exception e) {
|
|
JLabel texte = new JLabel("<html><p>La base de données des listes des étudiants<br>n'est pas située dans le même répertoire que celui de l'application.</p></html>");
|
|
JOptionPane.showMessageDialog(null, texte);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public boolean isHasliste() {
|
|
return Hasliste;
|
|
}
|
|
|
|
public void setHasliste(boolean hasliste) {
|
|
Hasliste = hasliste;
|
|
}
|
|
|
|
}
|