public static void IKAnalysis(String str) throws IOException {
Analyzer anal=new IKAnalyzer(true);
StringReader reader=new StringReader(str);
//分词
TokenStream ts=anal.tokenStream("", reader);
CharTermAttribute term=ts.getAttribute(CharTermAttribute.class);
//遍历分词数据
while(ts.incrementToken()){
String s=term.toString();
System.out.println(s+" ");
}
reader.close();
// System.out.println();
}
public static void main(String[] args) throws IOException {
String d="student brian comput scienc depart univers wisconsin dayton street madison offic email wisc offic phone home phone advisor david wood tabl content interest schedul summer ”;
IKAnalysis(d);
}
所需jar包在csdn中:
http://download.csdn.net/detail/alt_lb/9812915