mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-22 06:41:41 +01:00
Merge pull request #7384 from alvasw/file_keywork_scanner_close_file_descriptors
FileUtils: Close files after scanning for keywords
This commit is contained in:
commit
16a0f45d11
1 changed files with 5 additions and 4 deletions
|
@ -263,10 +263,11 @@ public class FileUtil {
|
|||
}
|
||||
|
||||
public static boolean doesFileContainKeyword(File file, String keyword) throws FileNotFoundException {
|
||||
Scanner s = new Scanner(file);
|
||||
while (s.hasNextLine()) {
|
||||
if (s.nextLine().contains(keyword)) {
|
||||
return true;
|
||||
try (Scanner s = new Scanner(file)) {
|
||||
while (s.hasNextLine()) {
|
||||
if (s.nextLine().contains(keyword)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Add table
Reference in a new issue