Search
 
SCRIPT & CODE EXAMPLE
 

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);
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: anagram java program 
Java :: how to add to arras java 
Java :: javafx detect collision 
Java :: How to create a disjoint-set data structure, in Java? 
Java :: java code to reverse an integer 
Java :: spigot execute command as player 
Java :: random password generator java 
Java :: Java How to use SortedMap? 
Java :: print line in jjava 
Java :: how to move from one activity to another in android studio on button click 
Java :: loop through array java 
Java :: read file in java 
Java :: java queue 
Java :: navigate from one fragment to another android 
Java :: how to take an element out of an array at a certain index in java 
Java :: what is import java.io.*? 
Java :: test if string is float java 
Java :: java cheat sheet 
Java :: zip file java 
Java :: what is the use of println 
Java :: java how to find the largest number in an arraylist 
Java :: java game 
Java :: data java 
Java :: kotlin string interpolation 
Java :: get first letter of string in array java 
Java :: execute code after delay java 
Java :: java selenium send keys numbers 
Java :: how to read file from assets folder in android 
Java :: initialize arraylist in 1 line in java 
Java :: how to do the maximum of three numbers in java 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =