// Path: src/main/java/org/apache/lucene/analysis/kr/morph/MorphException.java
// public class MorphException extends RuntimeException {
// 
//     private static final long serialVersionUID = 7605164221652820591L;
// 
//     public MorphException() {
//         super();
//     }
// 
//     public MorphException(String message) {
//         super(message);
//     }
// 
//     public MorphException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public MorphException(Throwable cause) {
//         super(cause);
//     }
// }


import org.apache.lucene.analysis.kr.morph.MorphException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
/*
 * Copyright 2011-2013 the original author or authors.
 *
 * 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 org.apache.lucene.analysis.kr.utils;



/**
 * file utility class
 *
 * @author S.M.Lee
 */
public class FileUtil {

    private static final Logger log = LoggerFactory.getLogger(FileUtil.class);

    public static InputStream getResourceFileStream(String filename) {

        ClassLoader classLoader = FileUtil.class.getClassLoader();
        InputStream stream = classLoader.getResourceAsStream(filename);
        if (stream == null) {
            stream = ClassLoader.getSystemResourceAsStream(filename);
        }
        return stream;
    }

    /**
     * Given a file name for a file that is located somewhere in the application
     * classpath, return a File object representing the file.
     *
     * @param filename The name of the file (relative to the classpath) that is
     *                 to be retrieved.
     * @return A file object representing the requested filename
     * @throws MorphException Thrown if the classloader can not be found or if
     *                        the file can not be found in the classpath.
     */
// Path: src/main/java/org/apache/lucene/analysis/kr/morph/MorphException.java
// public class MorphException extends RuntimeException {
// 
//     private static final long serialVersionUID = 7605164221652820591L;
// 
//     public MorphException() {
//         super();
//     }
// 
//     public MorphException(String message) {
//         super(message);
//     }
// 
//     public MorphException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public MorphException(Throwable cause) {
//         super(cause);
//     }
// }


// Path: src/main/java/org/apache/lucene/analysis/kr/utils/FileUtil.java
import org.apache.lucene.analysis.kr.morph.MorphException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;

/*
 * Copyright 2011-2013 the original author or authors.
 *
 * 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 org.apache.lucene.analysis.kr.utils;



/**
 * file utility class
 *
 * @author S.M.Lee
 */
public class FileUtil {

    private static final Logger log = LoggerFactory.getLogger(FileUtil.class);

    public static InputStream getResourceFileStream(String filename) {

        ClassLoader classLoader = FileUtil.class.getClassLoader();
        InputStream stream = classLoader.getResourceAsStream(filename);
        if (stream == null) {
            stream = ClassLoader.getSystemResourceAsStream(filename);
        }
        return stream;
    }

    /**
     * Given a file name for a file that is located somewhere in the application
     * classpath, return a File object representing the file.
     *
     * @param filename The name of the file (relative to the classpath) that is
     *                 to be retrieved.
     * @return A file object representing the requested filename
     * @throws MorphException Thrown if the classloader can not be found or if
     *                        the file can not be found in the classpath.
     */
    public synchronized static File getClassLoaderFile(String filename) throws MorphException {