Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class mainc {
- private static Scanner scan = new Scanner(System.in);
- private static Pattern ex = Pattern.compile("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}");
- private static Matcher match;
- static Writer output;
- static int loop = 0;
- public static void main(String[] args) throws IOException{
- System.out.println("Nmap log parser - Specify file location!");
- String filen = scan.next();
- File file = new File(filen);
- FileInputStream fis = new FileInputStream(file);
- BufferedInputStream bis = new BufferedInputStream(fis);
- DataInputStream dis = new DataInputStream(bis);
- output = new BufferedWriter(new FileWriter("nparsed"));
- while(dis.available()!=0){
- String it = dis.readLine();
- match = ex.matcher(it);
- while (match.find() ){
- System.out.println( match.group() );
- output.write(match.group()+"\n");
- loop++;
- }
- }
- output.close();
- System.out.println("Done parsing the Nmap log.\n"+loop+" ips total.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement