Browse Source

小修改

liuyuqi 4 years ago
parent
commit
435f5cd869
2 changed files with 12 additions and 6 deletions
  1. 12 5
      src/me/yoqi/composename/Compose.java
  2. 0 1
      src/qh/lqg/utils/TimeHelper.java

+ 12 - 5
src/me/yoqi/composename/Compose.java

@@ -28,18 +28,26 @@ public class Compose {
 		System.out.println("程序开始时间:" + df.format(new Date()));// new
 																// Date()为获取当前系统时间
 		new Compose().getComposeName();
-//		new Compose().countNum(resultUrl);
+		new Compose().countNum(resultUrl);
 		long endTime = System.currentTimeMillis();
 		System.out.println("程序结束时间:" + df.format(new Date()));// new
 																// Date()为获取当前系统时间
 		System.out.println("总耗时" + TimeHelper.getTimeDiff(startTime, endTime));
 	}
 
+	/**
+	 * @param resultUrl
+	 * @throws Exception
+	 */
 	private void countNum(String resultUrl) throws Exception {
 		TextHelper textHelper = new TextHelper();
 		String allChinese = textHelper.readTextByLine(dataUrl);
 		char[] chars = allChinese.toCharArray();
 		String[] result2 = new String[30];
+		//初始化空字符
+		for (int i = 0; i < result2.length; i++) {
+			result2[i] = "";
+		}
 		for (int i = 0; i < chars.length; i++) {
 			int length = HanDict.getBH(chars[i]).length();
 			switch (length) {
@@ -133,12 +141,12 @@ public class Compose {
 			}
 		}
 		for (int i = 0; i < 24; i++) {
-			System.out.println((i + 1) + "笔画数: " + result2[i].substring(4));
+			System.out.println((i + 1) + "笔画数: " + result2[i]);
 		}
 	}
 
 	/**
-	 * getComposeName:(组合双词). <br/>
+	 * getComposeName:(组合双词), output:data/result.txt. <br/>
 	 *
 	 * @author liuyuqi
 	 * @throws Exception
@@ -164,8 +172,7 @@ public class Compose {
 		flag++;
 		TextHelper.writeText(resultUrl, result);
 		long endTime = System.currentTimeMillis();
-		System.out
-				.println("当前耗时:" + TimeHelper.getTimeDiff(startTime, endTime));
+		System.out.println("当前耗时:" + TimeHelper.getTimeDiff(startTime, endTime));
 		System.out.println(flag);
 	}
 }

+ 0 - 1
src/qh/lqg/utils/TimeHelper.java

@@ -43,7 +43,6 @@ public class TimeHelper {
 	}
 
 	public static String getTimeDiff(long startTime, long endTime) {
-		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 		long l = endTime - startTime;
 		long day = l / (24 * 60 * 60 * 1000);
 		long hour = (l / (60 * 60 * 1000) - day * 24);