List of usage examples for org.apache.lucene.analysis.core StopFilter incrementToken
@Override
public final boolean incrementToken() throws IOException
From source file:org.jboss.trumped.data.TikaSample.java
License:Open Source License
public static List<String> tokenizeString(Analyzer analyzer, String string) { List<String> result = new ArrayList<String>(); try {/*from w w w . java2 s .c o m*/ TokenStream stream = analyzer.tokenStream(null, new StringReader(string)); StopFilter stopFilter = new StopFilter(stream, StopWords.getSet()); stopFilter.reset(); while (stopFilter.incrementToken()) { result.add(stopFilter.getAttribute(CharTermAttribute.class).toString()); } stopFilter.close(); } catch (IOException e) { // not thrown b/c we're using a string reader... throw new RuntimeException(e); } return result; }