I have a txt file with users' names separated by line as follows:
diego
sergio
antonio
maria
diego
antonio
Note that names can repeat, and I would like to list and list only the distinguished names.
I made this method to list the whole file:
String strPath = DIRETORIO + ARQUIVO_FILE;
if (pathExists(strPath)) {
List<String> texto = Files.readAllLines(new File(strPath).toPath());
for (String linha : texto) {
System.out.println(linha);
}
} else {
System.out.println("arquivo não existe");
}
But I'm not sure how to adapt it to another method that does this distinct name count. How do I make this count?
Note: some names may come with a dot separating surname type
diego.felipe
, but each name and / or firstname is saved per line only.