how to find a word in a file java code example
Example: how to find a specific word in a text file in java
String wordToFind="Hello";
List<String> lines=Files.readAllLines(Path.of("yourFile.txt"));
for(int i=0;i<lines.size();i++){
int col;
while((col=lines.indexOf(wordToFind))!=-1){
System.out.println("found "+wordToFind+" in line "+i+" at column "+col);
}
}