function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
anjin reddy 9anjin reddy 9 

can you give ans for this question


  how to display total nummber of words in text file and total count using VF and Apex class
You can do something like
String txtBody = 'foo bar baz'; // Or pulled from whatever

List<String> words = txtBody.split('\\W');
Integer wordCount = words.size();

words.clear(); // To clear memory

anjin reddy 9anjin reddy 9
Hi Pcon,
   Thanks for reply 
 Actually my requirement is that reading words one by one  from one text file  and its has disply count of total number of words in that text file.

Thanks in Advance

Oh, well that's different.
String txtBody = 'foo bar foo baz';

Map<String, Integer> wordCount = new Map<String, Integer>();

for (String word : txtBody.split('\\W')) {
    if (!wordCount.containsKey(word)) {
        wordCount.put(word, 0);

    wordCount.get(word) += 1;

That should give you a map of words to their count.  Then you can do whatever you want with that map.