force the reader default charset to UTF_8 to compita

This commit is contained in:
Lion 2023-10-13 09:15:57 +08:00
parent 3ef87ff727
commit 7256345713
2 changed files with 11 additions and 1 deletions

View File

@ -112,6 +112,14 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>

View File

@ -9,6 +9,7 @@ package org.lionsoul.ip2region;
import org.lionsoul.ip2region.xdb.Searcher; import org.lionsoul.ip2region.xdb.Searcher;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class SearchTest { public class SearchTest {
@ -145,7 +146,8 @@ public class SearchTest {
Searcher searcher = createSearcher(dbPath, cachePolicy); Searcher searcher = createSearcher(dbPath, cachePolicy);
long count = 0, costs = 0, tStart = System.nanoTime(); long count = 0, costs = 0, tStart = System.nanoTime();
String line; String line;
final BufferedReader reader = new BufferedReader(new FileReader(srcPath)); final FileInputStream fis = new FileInputStream(srcPath);
final BufferedReader reader = new BufferedReader(new InputStreamReader(fis, StandardCharsets.UTF_8));
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
String l = line.trim(); String l = line.trim();
String[] ps = l.split("\\|", 3); String[] ps = l.split("\\|", 3);