2019.4.31

2019.4.31

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();
            }
        };
    }

你可能感兴趣的:(琉璃神社)