Bonjour,

compte le nombre de mots dans un fichier

voila le code:
Code : 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
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
 
 
public class ScannFile{
 
	/**
         * @param args
         * @throws FileNotFoundException 
         */
	  public static void main(String[] args) throws FileNotFoundException {
		// TODO Auto-generated method stub
		   File myFile = new File(" Nouveau Document texte");
		      System.out.print("nomber de mots :"+ countworld(myFile));
	    } 
 
             public static int countworld (File file) throws FileNotFoundException{
	         Scanner cwScan= new Scanner(file);
	         int count=0;
	             while(cwScan.hasNext())
	                          {count++;
	                          cwScan.next();
	                           }
	        return count;
	         }
 
 
}
je ne sais pas pourquoi il me dit :
Exception in thread "main" java.io.FileNotFoundException: Nouveau Document texte (Le fichier spécifié est introuvable)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.util.Scanner.<init>(Unknown Source)
at ScannFile.countworld(ScannFile.java:19)
at ScannFile.main(ScannFile.java:15)
Auriez-vous une solution à me proposer svp ?

Merci