Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.regex.*;
- class Proclog {
- int[] start() throws IOException {
- int lines[] = { 0,0 };
- BufferedReader br = new BufferedReader(new FileReader("kern.log"));
- String nextLine;
- Pattern pat=Pattern.compile("^(.{11})\\s(\\d\\d:\\d\\d:\\d\\d)\\s(\\S+)\\s(\\w+\\.\\w+)\\s(\\w+):\\s+(ACCEPT|REJECT|DROP)\\s+(.*$)");
- while( (nextLine=br.readLine()) != null ){
- Matcher mat=pat.matcher(nextLine);
- if( mat.find() ){
- lines[0]++;
- } else {
- lines[1]++;
- }
- }
- br.close();
- return lines ;
- }
- }
- public class L1 {
- public static void main(String []args) throws IOException {
- Proclog s;
- s=new Proclog();
- int[] n=s.start();
- System.out.println(n[0]+","+n[1]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement