All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ansj.dic.DicReader Maven / Gradle / Ivy

There is a newer version: 5.1.6
Show newest version
package org.ansj.dic;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;

import org.ansj.util.MyStaticValue;
import org.nlpcn.commons.lang.util.logging.Log;

/**
 * 加载词典用的类
 * 
 * @author ansj
 */
public class DicReader {

	private static final Log logger = MyStaticValue.getLog() ;

	public static BufferedReader getReader(String name) {
		// maven工程修改词典加载方式
		InputStream in = DicReader.class.getResourceAsStream("/" + name);
		try {
			return new BufferedReader(new InputStreamReader(in, "UTF-8"));
		} catch (UnsupportedEncodingException e) {
			logger.warn("不支持的编码", e);
		}
		return null;
	}

	public static InputStream getInputStream(String name) {
		// maven工程修改词典加载方式
		InputStream in = DicReader.class.getResourceAsStream("/" + name);
		return in;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy