Finding a specific information in a log file

package imeifinder;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

/**
 *
 * @author nurhak.kaya
 */
public class IMEIFinder {

    public static void main(String[] args) {

        try {
            FileInputStream fis = new FileInputStream(
                    "2011-11-15_runtime.log");
            DataInputStream dis = new DataInputStream(fis);
            BufferedReader br = new BufferedReader(new InputStreamReader(dis));
            String strLine;
            ArrayList list = new ArrayList();
         
            while ((strLine = br.readLine()) != null) {
                if (strLine.contains("<faultstring>An object referred to was not found")) {
                    try {
                        String s = strLine.substring(strLine.indexOf('(', 0)
                                + 1, strLine.indexOf(')', 0));
                        if (list.contains(s)) {
                            continue;
                        } else {
                            System.out.println(s);
                            list.add(s);
                        }

                    } catch (Exception ex) {
                        continue;
                    }
                }
            }
            dis.close();
            System.out.println("******************");
            System.out.println(list.size());

        } catch (Exception e) {
            System.err.println("Error: " + e.getMessage());
        }
    }
}

Comments

Popular posts from this blog

Solution for "Can not obtain Oracle client information from registry"

Solution for the fault: "System.Diagnostics.Process.Start is not working on IIS, but working on ASP.NET Development Server"

Getting Umbraco Content - IPublishedContent vs IContent vs Node vs Document