I got the next code with the objective of read a file, and print the third string present on a line, the file is like that:
Reforma_Protestante - ABSTRACCAO|ACONTECIMENTO - IDEIA|EFEMERIDE
Europa - LOCAL - HUMANO
Cativeiro_Babilónica_da_igreja - ACONTECIMENTO - EFEMERIDE
Avignon - ACONTECIMENTO - EVENTO
The code I get only prints the lines of the text:
List<String> lines = Files.readAllLines(Paths.get("file.txt"));
...
for (int xi=0;xi < lines.size();xi++)
{
if(lines.get(xi).contains(tt[2]))
{
System.out.println(lines.indexOf(lines) );
com+= tt[0]+"\t"+tt[1]+"\t"+tt[2]+"\t"+"LINES.INDEXOF(2)"+"\t"+"LINES.INDEXOF(4)"+"\t"+tt[5]+"\t"+dt.get(tt[6])+"\n";
lines.remove(xi);
}
}
...
I want in the spot of LINES.INDEXOF(2) the word present on the file line(xi) and index 2, so it this case the fist one should be ABSTRACCAO|ACONTECIMENTO
And in the spot on LINES.INDEXOF(4) I want IDEIA|EFEMERIDE
I've tried lines.get(xi).indexof(2)
, but the output was -1