mirror of
https://github.com/Febbweiss/log-generator.git
synced 2026-03-04 22:25:40 +00:00
Fix reading ips.txt inside JAR
This commit is contained in:
@@ -1,18 +1,13 @@
|
|||||||
package com.github.vspiewak.loggenerator;
|
package com.github.vspiewak.loggenerator;
|
||||||
|
|
||||||
import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureDSA;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.InputStream;
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
@@ -21,8 +16,13 @@ public class Utils {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
URI uri = Thread.currentThread().getContextClassLoader().getResource("ips.txt").toURI();
|
InputStream is = Utils.class.getClassLoader().getResourceAsStream("ips.txt");
|
||||||
ips.addAll(Files.readAllLines(Paths.get(uri), StandardCharsets.UTF_8));
|
Scanner scan = new Scanner(is);
|
||||||
|
while (scan.hasNext()) {
|
||||||
|
String ip = scan.next().trim();
|
||||||
|
if (ip.length() > 0)
|
||||||
|
ips.add(ip);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error during ip read/parsing", e);
|
log.error("Error during ip read/parsing", e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user