Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- import java.lang.*;
- public class dab
- {
- public static void main(String args[])
- {
- String name = " ";
- int yes = 0;
- Scanner console = new Scanner(System.in);
- int letter = 0;
- int digit = 0;
- int space = 0;
- int special = 0;
- char ch;
- int i = 0;
- while (yes != 1)
- {
- try
- {
- System.out.println("Enter the name of the file");
- name = console.nextLine();
- Scanner inFile = new Scanner(new FileReader(name));
- yes = 1;
- while(inFile.hasNext())
- {
- ch = console.next().charAt(i);
- if (Character.isSpaceChar(ch) == true)
- space = space + 1;
- else if (Character.isDigit(ch) == true)
- digit = digit + 1;
- else if (Character.isLetter(ch) == true)
- letter = letter + 1;
- else
- special = special + 1;
- i++;
- }
- }
- catch (FileNotFoundException error)
- {
- System.out.println("Error, file not found");
- }
- }
- console.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement