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
|
public static void main(String[] args)
{
System.out.println("Date de début : " + new Date());
File fich = new File("C:\\FTP\\test_java.txt");
int n;
char c;
String mot = "";
Collection<String> col = new ArrayList<String>();
try {
FileReader fr = new FileReader(fich);
while ((n = fr.read()) != -1)
{
c =(char) n;
if (c != ' ' && c != '\r' && c != '\n' && c != '.' && c != ',' && c != ';' && c != ':'
&& c != '!' && c != '?' && c != '/' && c != '\\' && c != '$' && c != '"'
&& c != '&' && c != '(' && c != ')' && c != '[' && c != ']'
&& c != '{' && c != '}' && c != '@' && c != '*' && c != '%')
mot = mot + c;
else
{
if (mot.length() > 3 && !col.contains(mot.toLowerCase()))
{
col.add(mot.toLowerCase());
}
mot = "";
}
}
fr.close();
col.clear();
col = null;
System.out.println("Date de fin : " + new Date());
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} |
Partager