|
@@ -1,6 +1,8 @@
|
|
package me.yoqi.composename;
|
|
package me.yoqi.composename;
|
|
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Date;
|
|
|
|
|
|
import qh.lqg.utils.Messages;
|
|
import qh.lqg.utils.Messages;
|
|
import qh.lqg.utils.TextHelper;
|
|
import qh.lqg.utils.TextHelper;
|
|
@@ -17,7 +19,9 @@ import qh.lqg.utils.TextHelper;
|
|
public class Compose {
|
|
public class Compose {
|
|
|
|
|
|
public static void main(String args[]) throws Exception {
|
|
public static void main(String args[]) throws Exception {
|
|
-
|
|
|
|
|
|
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置日期格式
|
|
|
|
+ System.out.println(df.format(new Date()));// new Date()为获取当前系统时间
|
|
|
|
+ long starTime = System.currentTimeMillis();
|
|
String dataUrl = Messages.getString("Compose.data");
|
|
String dataUrl = Messages.getString("Compose.data");
|
|
String resultUrl = "data/result.txt";
|
|
String resultUrl = "data/result.txt";
|
|
String result = "";
|
|
String result = "";
|
|
@@ -25,18 +29,26 @@ public class Compose {
|
|
TextHelper textHelper = new TextHelper();
|
|
TextHelper textHelper = new TextHelper();
|
|
ArrayList<String> allChinese = textHelper.readTextByWord(dataUrl);
|
|
ArrayList<String> allChinese = textHelper.readTextByWord(dataUrl);
|
|
ArrayList<String> allChineseName = new ArrayList<String>();
|
|
ArrayList<String> allChineseName = new ArrayList<String>();
|
|
|
|
+ int flag = 0;
|
|
// 两两组合
|
|
// 两两组合
|
|
for (int i = 0; i < allChinese.size(); i++) {
|
|
for (int i = 0; i < allChinese.size(); i++) {
|
|
for (int j = i + 1; j < allChinese.size(); j++) {
|
|
for (int j = i + 1; j < allChinese.size(); j++) {
|
|
allChineseName.add(allChinese.get(i) + allChinese.get(j));
|
|
allChineseName.add(allChinese.get(i) + allChinese.get(j));
|
|
|
|
+ // 内存10万个值存一次磁盘,再清空再缓存。
|
|
|
|
+ flag++;
|
|
|
|
+ if (flag % 10000 == 0) {
|
|
|
|
+ for (int k = 0; k < allChineseName.size(); k++) {
|
|
|
|
+ result += allChineseName.get(k) + " ";
|
|
|
|
+ }
|
|
|
|
+ TextHelper.writeText(resultUrl, result);
|
|
|
|
+ allChineseName = new ArrayList<String>();
|
|
|
|
+ System.out.println(flag);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- // 打印输出
|
|
|
|
- for (int k = 0; k < allChineseName.size(); k++) {
|
|
|
|
- // result += allChineseName.get(k)+
|
|
|
|
- // System.getProperty("line.separator");
|
|
|
|
- result += allChineseName.get(k) + " ";
|
|
|
|
- }
|
|
|
|
- TextHelper.writeText(resultUrl, result);
|
|
|
|
|
|
+ long endTime = System.currentTimeMillis();
|
|
|
|
+ long Time = endTime - starTime;
|
|
|
|
+ System.out.println(df.format(new Date()));// new Date()为获取当前系统时间
|
|
|
|
+ System.out.println("总共耗时:" + Time);
|
|
}
|
|
}
|
|
}
|
|
}
|