Problème de chaîne de caractère
k
-
k -
k -
Bonjour,
svp qui peut m'aider c'est vraiment très urgent
j'ai une application en java
je suis bloqué au niveau de l'affichage de la résultat
alors voilà une parti de mon code
try {
String[]cmd = {"fw_anomalies.exe", "rule4.txt"};
Process process = Runtime.getRuntime().exec(cmd);
BufferedReader ds = new BufferedReader(new InputStreamReader(process.getInputStream()));
String lineCourante = ds.readLine();
while (lineCourante != null) {
System.out.println(lineCourante);// afiche la résultat dans le console
lineCourante = ds.readLine();
//ici je doit faire le test et l'affichage
}
} catch (IOException ioe){
ioe.getMessage();
}
mais mon problème et de ne pas afficher tout le contenu du résultat je veut que les ligne qui commence par un nombre entier ou la chaine "Number"
voilà mon résultat:
$$$$$$$$$$ ISIMS $$$$$$$$$$$$
size_cand = 4
searching anomalies with respect to rule 0
1 is up redundant with 0
2 is a generalisation of 0
3 is partial redundant with 0
$$$$$$$$$$ ISIMS $$$$$$$$$$$$
size_cand = 2
searching anomalies with respect to rule 2
2 is in correlation with 1
$$$$$$$$$$ ISIMS $$$$$$$$$$$$
size_cand = 3
searching anomalies with respect to rule 3
3 is shadowed by 2
3 is down redundant with 1
$$$$$$$$$$ ISIMS $$$$$$$$$$$$
size_cand = 1
$$$$$$$$$$ ISIMS $$$$$$$$$$$$
size_cand = 1
$$$$$$$$$$ ISIMS $$$$$$$$$$$$
size_cand = 1
Sans matrice:
Nombre noeuds generes = 26
TAREK --- CHALLENGE IS TO PRINT THIS LINE !
SUMMARY!
search time was 0.15000 seconds
Number of anomlies 6
Number of incohernce 3
Number of correaltion 1
Number of shadowing 1
Number of genaralization 1
Number of redundancy 3
Number of partial redundancy 1
Number of down redundancy 1
Number of up redundancy 1
Number of cut rule application 3
Number of nodes 26
total memory 28704
svp qui peut m'aider c'est vraiment très urgent
j'ai une application en java
je suis bloqué au niveau de l'affichage de la résultat
alors voilà une parti de mon code
try {
String[]cmd = {"fw_anomalies.exe", "rule4.txt"};
Process process = Runtime.getRuntime().exec(cmd);
BufferedReader ds = new BufferedReader(new InputStreamReader(process.getInputStream()));
String lineCourante = ds.readLine();
while (lineCourante != null) {
System.out.println(lineCourante);// afiche la résultat dans le console
lineCourante = ds.readLine();
//ici je doit faire le test et l'affichage
}
} catch (IOException ioe){
ioe.getMessage();
}
mais mon problème et de ne pas afficher tout le contenu du résultat je veut que les ligne qui commence par un nombre entier ou la chaine "Number"
voilà mon résultat:
$$$$$$$$$$ ISIMS $$$$$$$$$$$$
size_cand = 4
searching anomalies with respect to rule 0
1 is up redundant with 0
2 is a generalisation of 0
3 is partial redundant with 0
$$$$$$$$$$ ISIMS $$$$$$$$$$$$
size_cand = 2
searching anomalies with respect to rule 2
2 is in correlation with 1
$$$$$$$$$$ ISIMS $$$$$$$$$$$$
size_cand = 3
searching anomalies with respect to rule 3
3 is shadowed by 2
3 is down redundant with 1
$$$$$$$$$$ ISIMS $$$$$$$$$$$$
size_cand = 1
$$$$$$$$$$ ISIMS $$$$$$$$$$$$
size_cand = 1
$$$$$$$$$$ ISIMS $$$$$$$$$$$$
size_cand = 1
Sans matrice:
Nombre noeuds generes = 26
TAREK --- CHALLENGE IS TO PRINT THIS LINE !
SUMMARY!
search time was 0.15000 seconds
Number of anomlies 6
Number of incohernce 3
Number of correaltion 1
Number of shadowing 1
Number of genaralization 1
Number of redundancy 3
Number of partial redundancy 1
Number of down redundancy 1
Number of up redundancy 1
Number of cut rule application 3
Number of nodes 26
total memory 28704
A voir également:
- Problème de chaîne de caractère
- Caractère spéciaux - Guide
- Caractère ascii - Guide
- Caractere speciaux - Guide
- Plus de chaine tv - Guide
- Caractere vide - Guide
2 réponses
Bonjour,
Je te conseille de regarder du côté des expressions régulières :
http://docs.oracle.com/javase/1.4.2/docs/api/java/util/regex/Matcher.html
Un exemple bateau juste pour te donner une idée :
Donnera en sortie :
La ligne suivante commence par Number : Number blablabla
La ligne suivante ne commence pas par Number : Ne commence pas par Number
Je te conseille de regarder du côté des expressions régulières :
http://docs.oracle.com/javase/1.4.2/docs/api/java/util/regex/Matcher.html
Un exemple bateau juste pour te donner une idée :
import java.util.regex.Pattern;
public class Test {
public static void main(String[] args) {
String avec = "Number blablabla";
String sans = "Ne commence pas par Number";
// On définit l'expression régulière
Pattern p = Pattern.compile("^Number.*");
// on vérifie comment la chaine "avec" se comporte
if(p.matcher(avec).matches()){
System.out.println("La ligne suivante commence par Number : "+avec);
}
// de même avec la chaine "sans"
if(p.matcher(sans).matches()){
System.out.println("La ligne suivante commence par Number : "+sans);
}
else{
System.out.println("La ligne suivante ne commence pas par Number : "+sans);
}
}
}
Donnera en sortie :
La ligne suivante commence par Number : Number blablabla
La ligne suivante ne commence pas par Number : Ne commence pas par Number