import java.util.*; import java.io.*; public class MyClass { public static void main(String args[]) {
}
boolean findStringInFile(String filePath, String str) throws FileNotFoundException { File file = new File(filePath); Scanner scanner = new Scanner(file); // read the file line by line while (scanner.hasNextLine()) { String line = scanner.nextLine(); if (line.contains(str)) { scanner.close(); return true; } } scanner.close(); return false; } }
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Can you answer this question?
Write Answer1 Answers