Skip to content

Commit cac2ab7

Browse files
committed
Java 8 support
1 parent 469d603 commit cac2ab7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/main/java/org/fastfilter/tools/BuildFilterFile.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ public static void main(String... args) throws IOException {
1919
if (args.length != 1) {
2020
System.out.println("Usage: java " + BuildFilterFile.class.getName() + " <textFile>\n"
2121
+ "Builds a .filter file from a text file that contains SHA-1 hashes and counts.");
22+
// see also https://haveibeenpwned.com/passwords
2223
return;
2324
}
2425
String textFile = args[0];
2526
String filterFileName = textFile + ".filter";
2627
long start = System.nanoTime();
27-
LineNumberReader lineReader = new LineNumberReader(new FileReader(textFile, Charset.forName("LATIN1")));
28+
LineNumberReader lineReader = new LineNumberReader(
29+
new FileReader(new File(textFile), Charset.forName("LATIN1")));
2830
new File(filterFileName).delete();
2931
RandomAccessFile out = new RandomAccessFile(filterFileName, "rw");
3032
int lines = 0;
@@ -50,7 +52,7 @@ public static void main(String... args) throws IOException {
5052
}
5153
lastHash = hash;
5254
int dot = line.lastIndexOf(':');
53-
int count = Integer.parseInt(line, dot + 1, line.length(), 10);
55+
int count = Integer.parseInt(line.substring(dot + 1), 10);
5456
// set the lowest bit to 0
5557
long key = hash ^ (hash & 1);
5658
// if common, set the lowest bit
@@ -71,7 +73,8 @@ public static void main(String... args) throws IOException {
7173
out.close();
7274
}
7375

74-
private static void writeSegment(ArrayList<Long> keys, int segment, RandomAccessFile out) throws IOException {
76+
private static void writeSegment(ArrayList<Long> keys, int segment,
77+
RandomAccessFile out) throws IOException {
7578
long[] array = new long[keys.size()];
7679
for(int i=0; i<keys.size(); i++) {
7780
array[i] = keys.get(i);

0 commit comments

Comments
 (0)