import com.chenlb.mmseg4j.*; import com.chenlb.mmseg4j.analysis.ComplexAnalyzer; import java.io.StringReader; /** * Created by me on 17-5-9. */ public class WordSeg { public static void main(String[] args){ String txt = "Jim喜欢写代码"; Dictionary dic = Dictionary.getInstance(""); Seg seg = new ComplexSeg(dic); MMSeg mmSeg = new MMSeg(new StringReader(txt), seg); Word word = null; try { while ((word = mmSeg.next()) != null) { System.out.print(word + "|"); } } catch (Exception e) { System.exit(0); } } }