71 lines
2.1 KiB
Java
71 lines
2.1 KiB
Java
package baseEvaluations;
|
|
|
|
import java.io.BufferedReader;
|
|
import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.io.IOException;
|
|
import java.io.InputStreamReader;
|
|
import java.nio.file.Paths;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
|
|
import MEPTL.commandes;
|
|
import cXML.Run;
|
|
|
|
public class ecritureBaseEvaluation {
|
|
|
|
public ecritureBaseEvaluation() {
|
|
String directoryName = "";
|
|
|
|
|
|
File file = null;
|
|
if(commandes.PathBaseEvaluationDefaut) {
|
|
directoryName = Paths.get("").toAbsolutePath().toString();
|
|
}else {
|
|
directoryName = commandes.PathBaseEvaluations;
|
|
}
|
|
|
|
if(commandes.os.contains("Win")) {
|
|
file = new File(directoryName + "\\" + commandes.NameBaseEvaluations);
|
|
}else {
|
|
file = new File(directoryName + "/" + commandes.NameBaseEvaluations);
|
|
}
|
|
|
|
|
|
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 baseToString = targetString.toString().replace("\t","").replace("\r", "").replace("\n", "").replaceAll(">/{1,}<","><");
|
|
|
|
Pattern p = Pattern.compile("<\\bevaluation\\b.*?name=\""+commandes.NameEvaluationCharger+".*?\\bevaluation\\b>");
|
|
Matcher m = p.matcher(baseToString.trim());
|
|
|
|
if(m.find()) {
|
|
baseToString=baseToString.substring(0,m.start())+ baseToString.substring(m.start(),baseToString.length());
|
|
}
|
|
|
|
// écriture du node
|
|
baseToString = Run.ecritureNode(commandes.evaluationChargeEnMemoire, 0).toString().replace("\t","").replace("\r", "").replace("\n", "").replaceAll(">/{1,}<","><") + baseToString;
|
|
|
|
}catch (Exception e) {
|
|
|
|
}
|
|
}
|
|
|
|
// try {
|
|
// Run.ecritureNodeEnXML(commandes.evaluationsBase, commandes.NameBaseEvaluations, directoryName, Run.TypeFile.Evaluation);
|
|
// } catch (IOException e) {
|
|
// e.printStackTrace();
|
|
// }
|
|
}
|
|
|
|
}
|