import java.io.*; import java.io.FileInputStream; public class MyDictionary { public int countCharacters(File myFile) { int charCount = 0; String data; try{ FileInputStream fStrm = new FileInputStream(myFile);
import java.io.*; import java.io.FileInputStream;
public class MyDictionary { public int countCharacters(File myFile) { int charCount = 0; String data; try{ FileInputStream fStrm = new FileInputStream(myFile); InputStreamReader fData= new InputStreamReader(fStrm); BufferedReader bReadLine = new BufferedReader(fData); while((data = bReadLine.readLine()) != null) { charCount += data.length(); } }catch(Exception ex){ ex.printStackTrace();} return charCount; } public int countWords(File myFile) { int wordCount = 0; String data; try{ FileInputStream fStrm = new FileInputStream(myFile); InputStreamReader fData = new InputStreamReader(fStrm); BufferedReader bReadLine= new BufferedReader(fData); while((data = bReadLine.readLine()) != null) { String[] wordList =data.split("\\s+"); wordCount+= wordList.length; } }catch(Exception ex){ ex.printStackTrace();} return wordCount; } public int countVowels(File myFile) { int vowelCount = 0; try{ String[] Numberofwords=null; FileReader fr = new FileReader(myFile); BufferedReader br = new BufferedReader(fr); String data; int fcount=0; while((data=br.readLine())!=null) { Numberofwords=data.split(" "); for(int i=0;i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started