Package kg.apc.io

Source Code of kg.apc.io.FileSystem

package kg.apc.io;

import java.io.*;
import java.nio.channels.FileChannel;
import org.apache.commons.io.filefilter.WildcardFileFilter;

public class FileSystem {

    public static boolean checkFileExistByPattern(String path, String pattern) {
        if (path == null) {
            path = ".";
        }
        File dir = new File(path);
        FileFilter ff = new WildcardFileFilter(pattern);
        File[] found = dir.listFiles(ff);
        return found != null ? found.length > 0 : false;
    }

    public static void copyFile(String source, String destination) throws IOException {
        FileChannel out = null;
        try {
            FileChannel in = new FileInputStream(source).getChannel();
            File outFile = new File(destination);
            out = new FileOutputStream(outFile).getChannel();
            in.transferTo(0, in.size(), out);
        } finally {
            if (out != null) {
                out.close();
            }
        }
    }
}
TOP

Related Classes of kg.apc.io.FileSystem

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.