Java help open user spec file , count user spec character,
Code: (java)
import java.util.Scanner;
import java.io.*;
public class progChal6
{
public static void main(String[] args) throws IOException
{
//needed for scanner class
Scanner kb = new Scanner(System.in);
String filename; // file name
int charCount = 0;
// get users filename
System.out.print("Enter the file name: ");
filename = kb.nextLine();
Scanner inputFile = new Scanner(filename);
// get users character
System.out.print("Please enter a character: ");
char userChar = kb.nextLine().charAt(0);
// tell the user what the program does
System.out.println("\n****This program will return how many times" +
" the character you entered showed up in" +
" the string you entered.****");
while(inputFile.hasNext()) ;
{
(filename.charAt() == userChar);
{
charCount++;
}
}
System.out.println("\nThe specified character " +"\"" + userChar +
"\" is inside the string " + filename +
" " + charCount + " times.\n");
inputFile.close();
}
}













