MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / main

Method main

strings/ThreatAnalyzer.java:16–28  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

14 "58.27.82.161@08/12/2015\n" +
15 "[Next log section with different data format]";
16 public static void main(String[] args) {
17 Scanner scanner = new Scanner(threatData);
18 String pattern = "(\\d+[.]\\d+[.]\\d+[.]\\d+)@" +
19 "(\\d{2}/\\d{2}/\\d{4})";
20 while(scanner.hasNext(pattern)) {
21 scanner.next(pattern);
22 MatchResult match = scanner.match();
23 String ip = match.group(1);
24 String date = match.group(2);
25 System.out.format(
26 "Threat on %s from %s%n", date,ip);
27 }
28 }
29}
30/* Output:
31Threat on 08/10/2015 from 58.27.82.161

Callers

nothing calls this directly

Calls 4

nextMethod · 0.65
hasNextMethod · 0.45
matchMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected