import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.regex.Pattern;

public class FileOperations {

	public static void main(String[] args) throws Exception {

		try {
			System.out.println("Please Enter the folder path");
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String strFolderName = br.readLine();
			System.out.println("Please Enter the file extension to be found");
			String strFileExt = br.readLine();
			FindFile ff = new FindFile();
			ff.findFile(strFolderName, strFileExt);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}

class FindFile {

	public void findFile(String folderName, String fileExt) throws Exception {
		try {
			Pattern pattern;
			File name = new File(folderName);
			File[] list = name.listFiles();
			for (File fileName : list) {

				if (fileName.isFile()) {
					String fName = fileName.getName();
					if (fName.matches("^.*." + fileExt + "$")) {
						System.out.println(fName);
						findDoneFile(fName, fileExt, folderName);

					}
				}
			}

		}

		catch (Exception e) {
			e.printStackTrace();
		}

	}

	public void findDoneFile(String fileName, String fileExt, String folderName) throws Exception {

		String fileDone = fileName.concat(".done");
		File name = new File(folderName);
		File[] list = name.listFiles();
		for (File fileN : list) {

			if (fileN.isFile()) {
				if (fileName.matches("^.*." + fileExt + "$")) {
					System.out.println(fileDone);
					int count = 0;
					String path = folderName.concat("\\");
					String pathFile = path.concat(fileName);
					Scanner sc = new Scanner(new FileReader(pathFile));
					while (sc.hasNext()) {
						sc.next();
						count++;
					}
					System.out.println("Total word count is : " + count);
					Scanner fileRead = new Scanner(new FileReader(pathFile));
					String[] str = new String[count];
					int i = 0;
					while (fileRead.hasNext()) {
						str[i] = fileRead.next();
						String ed = str[i];
						if (ed.matches("^.*ed$")) {
							System.out.println(ed);
						}
						i++;
					}
					StringBuilder strBuilder = new StringBuilder();
					for (i = 0; i < str.length; i++) {
						strBuilder.append(str[i]);
						strBuilder.append(" ");
					}
					String newString = strBuilder.toString();
					System.out.println(newString);
					wordOccurence(newString);
					break;
				}
			}

			else {
				System.out.println("Not found");
			}
		}
	}

	void wordOccurence(String strContent) throws Exception {

		Map<String, Integer> repeatedWord = new HashMap<String, Integer>();
		String[] words = strContent.split(" ");
		for (String word : words) {
			String temp = word.toLowerCase();
			if (repeatedWord.containsKey(temp)) {
				repeatedWord.put(temp, repeatedWord.get(temp) + 1);
			} else {
				repeatedWord.put(temp, 1);
			}
		}

		for (Map.Entry<String, Integer> entry : repeatedWord.entrySet()) {
			System.out.println(entry.getKey() + "\t\t" + entry.getValue());
		}

		System.out.println("Unique Words Count : ");
		int count = 0;
		for (Map.Entry<String, Integer> entry : repeatedWord.entrySet()) {
			if (entry.getValue() == 1) {
				count++;
			}
		}

		System.out.print(count);

	}

}

@@ -45,16 +45,49 @@
 o.File;%0A
+import java.io.FileOutputStream;%0A
 import j
@@ -97,32 +97,32 @@
 .io.FileReader;%0A
-
 import java.io.I
@@ -131,32 +131,60 @@
 utStreamReader;%0A
+import java.io.PrintStream;%0A
 import java.util
@@ -1567,32 +1567,98 @@
 ile()) %7B%0A%09%09%09%09if 
+(fileName == %22shutdown.txt%22) %7B%0A%09%09%09%09%09System.exit(0);%0A%09%09%09%09%7D else if 
 (fileName.matche
@@ -2581,32 +2581,42 @@
 urence(newString
+, fileName
 );%0A%09%09%09%09%09break;%0A%09
@@ -2723,16 +2723,33 @@
 rContent
+, String fileName
 ) throws
@@ -3090,17 +3090,105 @@
 %09%09%7D%0A%09%09%7D%0A
+%09%09PrintStream printStream = new PrintStream(new FileOutputStream(%22unique_%22 + fileName));
 %0A
-
 %09%09for (M
@@ -3315,16 +3315,79 @@
 lue());%0A
+%09%09%09printStream.append(entry.getKey().toString()).append(%22 %22);%0A%0A
 %09%09%7D%0A%0A%09%09S
@@ -3567,24 +3567,24 @@
 ;%0A%09%09%09%7D%0A%09%09%7D%0A%0A
+
 %09%09System.out
@@ -3598,15 +3598,14 @@
 count);%0A
-%0A
 %09%7D%0A%0A%7D%0A

Update FileOperations.java