2 * Copyright (c) 2020 Pantheon Technologies, s.r.o. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.mdsal.binding.java.api.generator.test;
11 import java.io.FileNotFoundException;
12 import java.util.HashMap;
14 import java.util.Scanner;
16 final class FileSearchUtil {
17 private FileSearchUtil() {
21 static boolean findInFile(final File file, final String searchText) throws FileNotFoundException {
22 try (Scanner scanner = new Scanner(file)) {
23 while (scanner.hasNextLine()) {
24 final String nextLine = scanner.nextLine();
25 if (nextLine.contains(searchText)) {
33 static Map<String, File> getFiles(final File path) {
34 return getFiles(path, new HashMap<>());
37 private static Map<String, File> getFiles(final File path, final Map<String, File> files) {
38 final File [] dirFiles = path.listFiles();
39 for (File file : dirFiles) {
40 if (file.isDirectory()) {
41 return getFiles(file, files);
44 files.put(file.getName(), file);