Comparer un texte avec un tableau java
elhou
-
Edwyn Messages postés 105 Date d'inscription Statut Membre Dernière intervention -
Edwyn Messages postés 105 Date d'inscription Statut Membre Dernière intervention -
j'ai un prog qui faitla comparaison entre un fichier mots (existe dans le disque)et un tableau qui contiet des mots aussi tq il affiche le mots en commun esq cette instructionest juste?
...............................
................................
.................
String fichier ="C:\\Users\\ISMAIL\\Desktop\\client.txt" \\ emplacement du fichier
String mots[]; \\déclaraton du tableau
.......................................
................................
.............................
String[ ] tabMots = p.split(fichier);
{
if (fichier== mots[i] ); \\ ou je fait if(fichier.equals(mots[i]);
System.out.println ("mot commun " + i + " : " + mots[i]);
}
merci
...............................
................................
.................
String fichier ="C:\\Users\\ISMAIL\\Desktop\\client.txt" \\ emplacement du fichier
String mots[]; \\déclaraton du tableau
.......................................
................................
.............................
String[ ] tabMots = p.split(fichier);
{
if (fichier== mots[i] ); \\ ou je fait if(fichier.equals(mots[i]);
System.out.println ("mot commun " + i + " : " + mots[i]);
}
merci
A voir également:
- Comparer un texte avec un tableau java
- Waptrick java football - Télécharger - Jeux vidéo
- Jeux java itel - Télécharger - Jeux vidéo
- Tableau word - Guide
- Trier un tableau excel - Guide
- Tableau ascii - Guide
1 réponse
Salut,
si je comprend bien tu copie tout le text de ton fichier dans une string nommee fichier
puis apres tu regarde si fichier est egal a mots[i]
si tu veux savoir si mots[i] est contenu dans fichier c'est pas une comparaison d'egalite que tu dois utiliser mais plutot rechercher les occurence deta string dans le fichier...
int indexOf(String str)
Returns the index within this string of the first occurrence of the specified substring.
j'espere que ca repond a ta question
bye
si je comprend bien tu copie tout le text de ton fichier dans une string nommee fichier
puis apres tu regarde si fichier est egal a mots[i]
si tu veux savoir si mots[i] est contenu dans fichier c'est pas une comparaison d'egalite que tu dois utiliser mais plutot rechercher les occurence deta string dans le fichier...
int indexOf(String str)
Returns the index within this string of the first occurrence of the specified substring.
j'espere que ca repond a ta question
bye