public static Callable<Path> searchForTask(String word, Path path){
return () -> {
try(var in = new Scanner(path)){
while(in.hasNext()){
if(in.next().equals(word))
return path;
if(Thread.currentThread().isInterrupted()){
System.out.println("Search in "+path+" canceled.");
return null;
}
}
throw new NoSuchElementException();
}
};
}