Advertisement
haazee

L1.java

Aug 14th, 2014
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.regex.*;
  3.  
  4.  
  5. class Proclog {
  6.     int[] start() throws IOException {
  7.         int lines[] = { 0,0 };
  8.         BufferedReader br = new BufferedReader(new FileReader("kern.log"));
  9.         String nextLine;
  10.         Pattern pat=Pattern.compile("^(.{11})\\s(\\d\\d:\\d\\d:\\d\\d)\\s(\\S+)\\s(\\w+\\.\\w+)\\s(\\w+):\\s+(ACCEPT|REJECT|DROP)\\s+(.*$)");
  11.  
  12.  
  13.         while( (nextLine=br.readLine()) != null ){
  14.             Matcher mat=pat.matcher(nextLine);
  15.             if( mat.find() ){
  16.                 lines[0]++;
  17.             } else {
  18.                 lines[1]++;
  19.             }
  20.         }
  21.         br.close();
  22.         return lines ;
  23.     }
  24. }
  25.  
  26.  
  27.  
  28. public class L1 {
  29.  
  30.     public static void main(String []args) throws IOException {
  31.         Proclog s;
  32.  
  33.         s=new Proclog();
  34.         int[] n=s.start();
  35.         System.out.println(n[0]+","+n[1]);
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement