-
Notifications
You must be signed in to change notification settings - Fork 0
/
exercise03.java
30 lines (26 loc) · 993 Bytes
/
exercise03.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.io.FileInputStream;
import java.util.regex.*;
public class ReadFileLog {
public static void main(String args[]){
try{
//Asuming that file is in D drive
FileInputStream fin=new FileInputStream("D:\\testout.txt");
String inputString = null;
while((inputString=fin.read())!=-1){
int countNumber = countOccurances(inputString);
System.out.println("SprintsController => show action ran"+ countNumber+ "times");
}
fin.close();
}catch(Exception e){System.out.println(e);}
}
public static int countOccurances(String input) {
Pattern pattern = Pattern.compile("Processing by SprintsController#show as JSONAPI");
Matcher matcher = pattern.matcher(input);
int count = 0;
while (matcher.find()){
{
count++;
}
return count++;
}
}