I need to count the amount of a specific character in a file. The user will specify the char I just need to check how many chars there is in a file.
package assignmentoneqone;
import java.util.Scanner;
import java.io.FileReader;
import java.io.File;
import java.io.IOException;
/**
*
* @author Hannes
*/
public class AssignmentOneQOne {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner kb = new Scanner(System.in);
String fileLoc;
String userChar;
//User specify the file and character
System.out.println("Enter the file name");
fileLoc = kb.nextLine();
System.out.println("Enter a character");
userChar = kb.nextLine();
File file = new File(fileLoc);
try
{
FileReader fw = new FileReader(file);
This is where I should do my search for characters.
}
catch(IOException e)
{
System.out.println("The file does not exist.");
}
}
}