1) Write a program to find a repeated word? package com.repeat; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.HashMap; import java.util.Set; public class RepeatedWords { public static void main(String[] args) { //Creating wordCountMap which holds words as keys and their occurrences as values HashMap<String, Integer> wordCountMap = new HashMap<String, Integer>(); BufferedReader reader = null; try { //Creating BufferedReader object reader = new BufferedReader(new FileReader("C:\\sample.txt")); //Reading the first line into currentLine String currentLine = reader.readLine(); while (currentLine != null) { //splitting the currentLine
Comments
Post a Comment