top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Java: Implement a code to count the occurrences of each word in input file and write the word with count in output file?

+2 votes
233 views

Implement a code that counts the occurrences of each word in an input file and write the word along with corresponding count in an output file sorted by the words alphabetically.

Sample Input

Gaurav is  a Good Boy
Sita is a Good Girl
Tommy is  a Good Dog
Ram is a Good person

Sample Output

D:\>Java FileWordCount inputFile.txt outputFile.txt
    Boy : 1
    Dog : 1
    Gaurav : 1
    Girl : 1
    Good : 4
    Ram : 1
    Sita : 1
    Tommy : 1
    a : 4
    is : 4
    person : 1
posted Apr 22, 2017 by Azhar Keer

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

Similar Questions
0 votes

Given a sentence and a word, remove all occurrences of the word in the sentence.

For example, removing “is” from the sentence “This is a boy.” becomes “Th a boy.”

+4 votes

Design an algorithm to accept a string from the user. Count and print the number of times each character occurs in the given string. Example –
input string = "malayalam"
Output must be –
m – 2
a – 4
l – 2
y - 1

0 votes

Write a C code for the logic -
input: string, strong
output: strng

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...