
i need to to a project in java and the title is file parsing. i need to read a file or if a particular file is given i have to count the no of vowels, pick out some terms, and to display the details about that file... can anyone tell me how to do this...

import java.io.*;
class ParseFile
{
public static void main(String[] args) throws Exception
{
int total=0;
File f=new File("data.txt");
BufferedReader br=new BufferedReader(new FileReader(f));
String strLine = "";
String str = "";
while ((strLine = br.readLine()) != null) {
str += strLine;
}
String st = str.replaceAll(" ", "").toLowerCase();
char[] third = st.toCharArray();
System.out.println("Character Total");
for (int counter = 0; counter < third.length; counter++) {
if (third[counter]=='a' || third[counter]=='e' || third[counter]=='i' || third[counter]=='o' || third[counter]=='u') {
char ch = third[counter];
int count = 0;
for (int i = 0; i < third.length; i++) {
if (ch == third[i])
count++;
}
boolean flag = false;
for (int j = counter - 1; j >= 0; j--) {
if (ch == third[j])
flag = true;
}
if (!flag) {
System.out.println(ch + " " + count);
}
total++;
}
}
System.out.println("Total Vowels: "+total);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.