Bonjour, j'ai fichier texte dont je souhaiterai compter le nombre de ligne. Pour chaque fin de ligne j'ai ajouté /
voici une ligne du fichier:

nom:prenom:adresse:255:pooy:ghiko:jiel:@:0/

Maintenant je veux lire la ligne (on vas dire 3) je compte le nombre de ; avec le scanner, mais je bloque... je sais pas comment dire au scanner sc2 qu'apré 2 / Tu scan les :

Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 
public void ficheClientRecuperer(GestClientUI gestClientUI)
	{		
		try 
        {
			String champ;
			int i;
			int nbLigne= 0;
			int compteur= gestClientUI.getCompteur();
 
			Scanner sc = new Scanner(new File("Client.txt"));
			Scanner sc2 = new Scanner(new File("Client.txt"));
			sc.useDelimiter(Pattern.compile(":"));
			sc2.useDelimiter(Pattern.compile(";"));
			BufferedReader buff = new BufferedReader(new FileReader("Client.txt")); 
 
			for(i=0;i<compteur;i++)
			{	
 
				if(nbLigne == compteur)
				{
					champ = sc.next();
					gestClientUI.textNom.setText(champ);  
					champ = sc.next();
					gestClientUI.setStringPrenom(champ);
					champ = sc.next();
					gestClientUI.setStringAdresse(champ);    
					champ = sc.next();
					gestClientUI.setStringCodePostal(champ);
					champ = sc.next();
					gestClientUI.setStringVille(champ); 
					champ = sc.next();
					gestClientUI.setStringPays(champ);   
					champ = sc.next();
					gestClientUI.setStringTel(champ);   
					champ = sc.next();
					gestClientUI.setStringMel(champ);  
					champ = sc.next();
					stringCompteur = champ;
					compteur = Integer.parseInt(stringCompteur);
					gestClientUI.setCompteur(compteur);
				}
				nbLigne++;
				 //System.out.println (nbLigne);
			}
 
			sc.close();
        }

merci d'avance.