Skip to content

Commit

Permalink
Merge pull request #7384 from alvasw/file_keywork_scanner_close_file_…
Browse files Browse the repository at this point in the history
…descriptors

FileUtils: Close files after scanning for keywords
  • Loading branch information
alejandrogarcia83 authored Feb 6, 2025
2 parents a485887 + e9e49f4 commit 16a0f45
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions common/src/main/java/bisq/common/file/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,11 @@ public static void removeAndBackupFile(File dbDir, File storageFile, String file
}

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;
Expand Down

0 comments on commit 16a0f45

Please sign in to comment.