/*
 * Copyright (c) 2016, The Dattack team (http://www.dattack.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.dattack.jtoolbox.io;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Closeable;
import java.io.IOException;

/**
 * A collection of useful method to simplify the I/O operations.
 *
 * @author cvarela
 * @since 0.1
 */
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
public final class IOUtils {

    private static final Logger LOGGER = LoggerFactory.getLogger(IOUtils.class);

    /**
     * Closes a {@link Closeable} unconditionally.
     *
     * @param obj
     *            the object to close, may be null
     */
    public static void closeQuietly(final Closeable obj) {
        if (obj != null) {
            try {
                obj.close();
            } catch (final IOException e) {
                LOGGER.debug("Error closing object {}: {}", obj, e.getMessage());
            }
        }
    }

    private IOUtils() {
        // utility class
    }
}

@@ -657,16 +657,60 @@
 ox.io;%0A%0A
+import org.apache.commons.lang.StringUtils;%0A
 import o
@@ -726,16 +726,16 @@
 Logger;%0A
-
 import o
@@ -758,16 +758,17 @@
 actory;%0A
+%0A
 import j
@@ -812,16 +812,191 @@
 ception;
+%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.util.Collections;%0Aimport java.util.Set;%0Aimport java.util.stream.Collectors;%0Aimport java.util.stream.Stream;
 %0A%0A/**%0A *
@@ -1669,16 +1669,16 @@
 age());%0A
-
         
@@ -1700,16 +1700,971 @@
 %0A    %7D%0A%0A
+    /**%0A     * Scans the specified directory and returns the files and directories whose name contains the specified pattern.%0A     * This method is case-insensitive and null-safe.%0A     *%0A     * @param dir the directory to scan%0A     * @param pattern the pattern to find%0A     * @return the files and directories whose name contains the specified pattern%0A     * @throws IOException if an I/O error occurs when reading the directory%0A     */%0A    public static Set%3CPath%3E listFiles(Path dir, String pattern) throws IOException %7B%0A%0A        if (dir == null %7C%7C !Files.isDirectory(dir)) %7B%0A            return Collections.emptySet();%0A        %7D%0A%0A        try (Stream%3CPath%3E stream = Files.list(dir)) %7B%0A            return stream //%0A                    .filter(path -%3E StringUtils.isEmpty(pattern) //%0A                            %7C%7C StringUtils.containsIgnoreCase(path.getFileName().toString(), pattern)) //%0A                    .collect(Collectors.toSet());%0A        %7D%0A    %7D%0A%0A
     priv

add method to list objects into a directory