-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIpCounter.java
More file actions
33 lines (28 loc) · 872 Bytes
/
IpCounter.java
File metadata and controls
33 lines (28 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.ecwid.dev.ipcounter;
import java.io.FileNotFoundException;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
* Entry point of the App.
*
* @author unrealwork
*/
public class IpCounter {
private IpCounter() {
}
/**
* Count IPV4 addresses in specified text file and print an answer in standard output.
*
* @param args contain path to text file as first argument.
* @throws FileNotFoundException in case if specified file is not found.
*/
@SuppressWarnings("squid:S106")
public static void main(String... args) throws FileNotFoundException {
if (args.length == 0) {
throw new IllegalArgumentException("Path to file with IPs should be provided");
}
Path p = Paths.get(args[0]);
long count = IpUtil.countUnique(p);
System.out.println(count);
}
}