Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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);
    }
}
 
PREVIOUS NEXT
Tagged: #find #specific #word #text #file #java
ADD COMMENT
Topic
Name
3+3 =