Created
September 18, 2021 10:47
-
-
Save GaetanoPiazzolla/56b32f7931affdef6370819aad1ab1ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.nio.file.Files; | |
import java.nio.file.Path; | |
private final static String SEARCH_TOKEN = "searchtoken"; | |
public List<String> searchStandard(String pathFile) { | |
List<String> wholeData = Files.readAllLines(Path.of(pathFile)); | |
List<String> found = new ArrayList<>(); | |
for (String wholeDatum : wholeData) { | |
if (wholeDatum.contains(SEARCH_TOKEN)) | |
found.add(wholeDatum); | |
} | |
return found; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
related to medium article https://gae-piaz.medium.com/search-string-in-file-with-java-as-fast-as-possible-fedafdc7a3ee