import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
public class DataStreamExample {
public static void main(String[] args) throws IOException {
File f = new File("seminar.txt");
if (f.exists()) {
BufferedReader br = new BufferedReader(new FileReader(f));
String dat;
StringBuilder text = new StringBuilder();
while ((dat = br.readLine()) != null) {
text.append(dat);
}
String strArray[] = text.toString().replace("January", "").replace("February","").replace("March", "").replace("Week","").trim().split(" ");
boolean flag=false;
Integer sum=0;
for(String s :strArray) {
if(flag) {
try {
sum= sum + Integer.parseInt(s);
}catch(Exception e) {}
flag=false;
}else
flag=true;
}
System.out.println("Total Number of Student : "+sum);
} else
System.out.println("File Not Found...");
}
}
Heung min 0 Newbie Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
Tarek_2 26 Light Poster
Seymour_1 0 Newbie Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.