lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "McGibbney, Lewis John" <>
Subject tokensFromAnalysis
Date Thu, 02 Dec 2010 15:27:07 GMT
Hello List,

Having posted a couple of days ago, I have one last question regarding the following code

  public static Token[] tokensFromAnalysis(Analyzer analyzer, String text)
      throws IOException {
   TokenStream stream = analyzer.tokenStream("contents",
        new StringReader(text));
    ArrayList<Token> tokenList = new ArrayList<Token>();
    Token token = null;
    while ((token = != null) <-------
    Token[] tokens = new Token[tokenList.size()];
    for (int i = 0; i < tokens.length; i++)
      tokens[i] = tokenList.get(i);
    return (tokens);

I am getting an error on as highlighted. I am prompted to add a cast to stream,
however I then am faced with the problem of which object to pass... which I do not know.

while ((token = ((Object) stream).next()) != null)

Thank you

Glasgow Caledonian University is a registered Scottish charity, number SC021474

Winner: Times Higher Education's Widening Participation Initiative of the Year 2009 and Herald
Society's Education Initiative of the Year 2009,6219,en.html

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message