Compose.java 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package me.yoqi.composename;
  2. import java.util.ArrayList;
  3. import qh.lqg.utils.Messages;
  4. import qh.lqg.utils.TextHelper;
  5. /**
  6. * ClassName: Compose <br/>
  7. * Function: 对3500个汉字两两组合. <br/>
  8. * date: 2016年8月7日 上午11:51:28 <br/>
  9. *
  10. * @author liuyuqi
  11. * @version
  12. * @since JDK 1.7
  13. */
  14. public class Compose {
  15. public static void main(String args[]) throws Exception {
  16. String dataUrl = Messages.getString("Compose.data");
  17. String resultUrl = "data/result.txt";
  18. String result = null;
  19. TextHelper textHelper = new TextHelper();
  20. ArrayList<String> allChinese = textHelper.readTextByWord(dataUrl);
  21. ArrayList<String> allChineseName = textHelper.readTextByWord(dataUrl);
  22. // 两两组合
  23. for (int i = 0; i < 20; i++) {
  24. for (int j = i + 1; j < allChinese.size() - 1; j++) {
  25. allChineseName.add(allChinese.get(i) + allChinese.get(j));
  26. }
  27. }
  28. // 打印输出
  29. for (int k = 0; k < allChineseName.size(); k++) {
  30. result += allChineseName.get(k);
  31. }
  32. textHelper.writeText(resultUrl, result);
  33. }
  34. }