import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

import ProcessingLogic.Counter;
import StorageLogic.WordFrequency;

public class main {
	private static BufferedReader reader;
	/**
	 * @param args
	 * @throws FileNotFoundException 
	 */
	public static void main(String[] args) throws FileNotFoundException {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		if (promptStringOrFile()) {
			//String

		} else {
			//file
			System.out.println("Enter filename: ");
			String fileName=readInput();
			if (!ensureFileExists(fileName)) {
				throw new FileNotFoundException("File " + fileName + " does not exist!");
			}
		}
	}
	
	public static boolean ensureFileExists(String fileName) {
		return (new File(fileName)).exists();
	}
	
	public static boolean promptStringOrFile() {
		char cbuf[] = new char[2];
		do {
			System.out.println("Do you want to process standard (I)nput, or a (F)ile? I/F");
			try {
				cbuf[0]=reader.readLine().charAt(0);
			} catch (IOException e) {
				inputReadFailure(e);
			}
		} while ((!(cbuf[0]=='I' || cbuf[0]=='F')));
		if (cbuf[0]=='I') {
			return true;
		}
		else 
			return false;
	}
}