本文整理汇总了Java中org.apache.lucene.analysis.charfilter.HTMLStripCharFilter.close方法的典型用法代码示例。如果您正苦于以下问题:Java HTMLStripCharFilter.close方法的具体用法?Java HTMLStripCharFilter.close怎么用?Java HTMLStripCharFilter.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.analysis.charfilter.HTMLStripCharFilter
的用法示例。
在下文中一共展示了HTMLStripCharFilter.close方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filter
import org.apache.lucene.analysis.charfilter.HTMLStripCharFilter; //导入方法依赖的package包/类
private String filter(String value) {
StringBuilder out = new StringBuilder();
StringReader strReader = new StringReader(value);
try {
HTMLStripCharFilter html = new HTMLStripCharFilter(new BufferedReader(strReader));
char[] cbuf = new char[1024 * 10];
while (true) {
int count = html.read(cbuf);
if (count == -1)
break; // end of stream mark is -1
if (count > 0)
out.append(cbuf, 0, count);
}
html.close();
} catch (IOException e) {
throw new RuntimeException("Failed stripping HTML for value: "
+ value, e);
}
return out.toString();
}
示例2: stripHTML
import org.apache.lucene.analysis.charfilter.HTMLStripCharFilter; //导入方法依赖的package包/类
private Object stripHTML(String value, String column) {
StringBuilder out = new StringBuilder();
StringReader strReader = new StringReader(value);
try {
HTMLStripCharFilter html = new HTMLStripCharFilter(strReader.markSupported() ? strReader : new BufferedReader(strReader));
char[] cbuf = new char[1024 * 10];
while (true) {
int count = html.read(cbuf);
if (count == -1)
break; // end of stream mark is -1
if (count > 0)
out.append(cbuf, 0, count);
}
html.close();
} catch (IOException e) {
throw new DataImportHandlerException(DataImportHandlerException.SEVERE,
"Failed stripping HTML for column: " + column, e);
}
return out.toString();
}