检索中文工具(SearchZhUtil)3
来源:互联网 发布:淘宝网络电话 编辑:程序博客网 时间:2024/06/06 04:48
/**
* 读取文件,使用list返回文件内容,文件中的每一行就是list 的一个数据
*
* @param fileName
* @return List<String>
*/
public static List<String> readFile(String fileName) {
if (fileName == null || "".equals(fileName.trim())) {
return null;
}
fileName = fileName.trim();
BufferedReader reader = null;
List<String> contentList = null;
try {
reader = new BufferedReader(new InputStreamReader(
new FileInputStream(fileName), "utf-8"));
String content = null;
contentList = new ArrayList<String>();
while ((content = reader.readLine()) != null) {
contentList.add(content);
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
reader.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return contentList;
}
/**
* 写文件,每一个user是一条记录
*
* @param user
* @return boolean
*/
public static boolean writeFile(List<String> contents, String filePath) {
boolean isSuccess = false;
if (contents == null || contents.isEmpty()) {
return isSuccess;
}
if (filePath == null || "".equals(filePath.trim())) {
return isSuccess;
}
filePath = filePath.trim();
BufferedWriter writer = null;
try {
writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(filePath, true), "UTF-8"));
int count = 0;
int MAX = 500;
for (String content : contents) {
writer.write(content);
writer.write("/t/n");
count++;
if (count >= MAX) {
writer.flush();
count = 0;
}
}
writer.flush();
isSuccess = true;
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
writer.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return isSuccess;
}
- 检索中文工具(SearchZhUtil)3
- 检索中文工具(SearchZhUtil)
- 检索中文工具(SearchZhUtil)2
- oracle检索中文日期(varchar2)方法
- Oracle 全文检索 中文检索
- lucene是个全文检索工具 IKAnalyzer是个分词包 可以用来做中文的检索
- dspace不能检索中文
- Mysql 中文全文检索
- Dspace之中文检索
- Coreseek中文检索引擎
- solr中文全文检索
- MySQL中文全文检索
- 《信息检索》第十讲 中文数据库使用 及 相关工具详解
- 信息检索工具库
- sphinx全文检索工具
- javascript全文检索工具
- Lucene:全文检索工具
- elasticSearch 全文检索工具
- 好久没来了
- JNDI
- 《冒号课堂》连载之七——声明范式:目标决定行动
- 检索中文工具(SearchZhUtil)
- 检索中文工具(SearchZhUtil)2
- 检索中文工具(SearchZhUtil)3
- 【MLDN_李兴华】JAVA学习攻略+新书导读
- Java基础:第十二讲 循环结构
- DateTool(1)
- DateTool(2)
- DateTool(3)
- DateTool(4)
- 有缺陷的人能不能成功?
- 从C++ Primer 认识ISO C++