I have a file with words separated by * and lines separated by ~, I would like to count the specific word how many times it is appeared in the file.
For eg.
Input File:
AB*xyz*1234~
CD*mny*769~
MN*bvd*2345~
AB*zar*987~
Code:
for (line <- bufferedSource.getLines()) {
array = line.split("\\~")
for (row <- array ){
val splittedRow=row.split("\\*")
val cnt = splittedRow(0).contains("AB").count()
Here i am facing the issue in, how many times the word AB is present. Can you please help me how to get the count of specific words from an array. I am not able to use the keyword .count.
Kindly help me.