From b7e712163e9b106ebf3c32dc1057de8c15929154 Mon Sep 17 00:00:00 2001
From: zhangyilin <1357146670@qq.com>
Date: Fri, 28 Sep 2018 19:45:01 +0800
Subject: [PATCH 01/13] divide function
---
001003/.idea/compiler.xml | 6 +
001003/.idea/misc.xml | 103 +++
001003/.idea/modules.xml | 8 +
001003/.idea/vcs.xml | 7 +
001003/.idea/workspace.xml | 867 ++++++++++++++++++
001003/001003.iml | 11 +
001003/input.txt | 3 +
.../001003/WordCount/FileFunction.class | Bin 0 -> 1687 bytes
.../production/001003/WordCount/Main.class | Bin 0 -> 1017 bytes
.../production/001003/WordCount/Word.class | Bin 0 -> 4790 bytes
001003/out/production/001003/input.txt | 3 +
001003/result.txt | 0
001003/src/WordCount/FileFunction.java | 45 +
001003/src/WordCount/Main.java | 23 +
001003/src/WordCount/Word.java | 107 +++
001003/src/input.txt | 3 +
16 files changed, 1186 insertions(+)
create mode 100644 001003/.idea/compiler.xml
create mode 100644 001003/.idea/misc.xml
create mode 100644 001003/.idea/modules.xml
create mode 100644 001003/.idea/vcs.xml
create mode 100644 001003/.idea/workspace.xml
create mode 100644 001003/001003.iml
create mode 100644 001003/input.txt
create mode 100644 001003/out/production/001003/WordCount/FileFunction.class
create mode 100644 001003/out/production/001003/WordCount/Main.class
create mode 100644 001003/out/production/001003/WordCount/Word.class
create mode 100644 001003/out/production/001003/input.txt
create mode 100644 001003/result.txt
create mode 100644 001003/src/WordCount/FileFunction.java
create mode 100644 001003/src/WordCount/Main.java
create mode 100644 001003/src/WordCount/Word.java
create mode 100644 001003/src/input.txt
diff --git a/001003/.idea/compiler.xml b/001003/.idea/compiler.xml
new file mode 100644
index 0000000..61a9130
--- /dev/null
+++ b/001003/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/001003/.idea/misc.xml b/001003/.idea/misc.xml
new file mode 100644
index 0000000..b1a34a2
--- /dev/null
+++ b/001003/.idea/misc.xml
@@ -0,0 +1,103 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Class structureJava
+
+
+ Code maturity issuesJava
+
+
+ Code style issuesJava
+
+
+ Google Web Toolkit issues
+
+
+ JUnit issuesJava
+
+
+ Java
+
+
+ Java 5Java language level migration aidsJava
+
+
+ Java 7Java language level migration aidsJava
+
+
+ Java 8Java language level migration aidsJava
+
+
+ Java language level migration aidsJava
+
+
+ Javadoc issuesJava
+
+
+ Performance issuesJava
+
+
+ Spring
+
+
+ Spring AOPSpring
+
+
+ TestNGJava
+
+
+ Threading issuesJava
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/001003/.idea/modules.xml b/001003/.idea/modules.xml
new file mode 100644
index 0000000..495f668
--- /dev/null
+++ b/001003/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/001003/.idea/vcs.xml b/001003/.idea/vcs.xml
new file mode 100644
index 0000000..64893e5
--- /dev/null
+++ b/001003/.idea/vcs.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/001003/.idea/workspace.xml b/001003/.idea/workspace.xml
new file mode 100644
index 0000000..64c457a
--- /dev/null
+++ b/001003/.idea/workspace.xml
@@ -0,0 +1,867 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ DEFINITION_ORDER
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No facets are configured
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 9.0
+
+
+
+
+
+
+
+
+
+
+
+ 001003
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/001003/001003.iml b/001003/001003.iml
new file mode 100644
index 0000000..c90834f
--- /dev/null
+++ b/001003/001003.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/001003/input.txt b/001003/input.txt
new file mode 100644
index 0000000..59cc749
--- /dev/null
+++ b/001003/input.txt
@@ -0,0 +1,3 @@
+ Today, people's lifestyle pace is very fast and a lot of young people feel the great pressure when they come to the job market. Before I graduated from college, I started to come to the job market. It was hard for me to get the job I wanted. I got rejected many times, but when the moment I was hired, I felt the victory.
+ I still remembered the day when I was interviewed. Before I came to the company, I had practised many times and my friends pretended to be the employers, asking me all kinds of questions. So I made some preparations and believed that I wouldn't lose control. At the beginning, the employers asked me some simple questions, which I had prepared, so I felt confident.But when they asked me about the company, I forgot to search enough information. But I told myself to calm down,so I expressed my wish to work here. Two days later, I was informed that I got the job. My heart was beating very fast,just liked I had conquered the world.
+ The experience of being success helps me to be stronger and gain more confidence.
\ No newline at end of file
diff --git a/001003/out/production/001003/WordCount/FileFunction.class b/001003/out/production/001003/WordCount/FileFunction.class
new file mode 100644
index 0000000000000000000000000000000000000000..9c42a38abb6ee1dc18b67da0ce4734df0d42d945
GIT binary patch
literal 1687
zcmZuyOK%%h7(LgXWbDZ#PU1W%O?WnT9yNtRpe}_vsUeU!r4C8m@S50@bc!=$jmOX|
zSs+$ONJvOsus{g0;!zg1grV&D9kg`EA3%t6$M(cgVr%Z5`#sNhzI*Td`QNYi0G!9J
zhDp4n;(~?{(sH;chnJ(cgjXVXRl{XuR4i$TO0#7ZS2XC-vJY7muW5+kbrmZbhNSQf
zys2RoYjVh`Sl2Lyt18}7aZRB2qGem&C4q1vxhbG5IVDpdwrbgCuC~8px*Nt$nUdjE
zr)ZQn4cC(EwovhIT2+CG)h)*@EjcyYOJ%LHnXTDH&vNXvfPT$1N?F(0mvVvm#Of{M
zBO_Hd?7dXpb1i!>ootCLCzYw~?wYPyl0K$OZ>3^*H)ZZ)PSoxC5eEWqnSnlGtLh4z
z3dAdRrRFh}Y3v7aLpwB?2uzOU?azBg@xwKv;@8PW2xwPs7tM;Ss;VL{(6{AUp1I+)
z>Y6#BuH&F3!C|N735*4~*K1yYkLU$S8tw87vQnoO9osW)k1Zsgyi;?FW-I-WoI0$Z
zm1OC71gA*9PaLV022!@6<85r}*utiY>pIS%K(ZeG)OdLB%ln^x_uz+b|NiF32VZ^m
zSF?Wqi_ic0?GqI@bZlco;B#<;+EM<;P~=_RChNJmF~v=dVM
zE*sU+O6P9ARJ^C-eSDyT_3ogkqa=%t`}Y183*hN6rE2WtjVdsB=(E0a%Pg`-tuW+n
zWjzSP=A6)J+1Fn4wpI0b7AIr41blUpuIuayBw8hr+|CG$bSUnoSD@!(
zxyd;vwlgwTPqFM&xsLg8{6n(g8buS2V}e(f{DmRp*5mjnS1HbdbI)u8;x1o8IL)!w
z7e+9}cfDnRX*|Z2V5lc(C7pjq5C6b&6QROf1L3v#I+Q!mIQ85?{1@~Nt93-0h!z^q
z{%E4F(1b2c`x_X@H4!T;G%$EUnN)seoUosJ3M$|Gd36q8oEPOZ1~G#;7BRwWb=t>t
zzLmF)i3so{o+7p=(s&wYh;NY*W{_aa%Y2fUg@QT8jUx0f##PM6u)w84r?Y%gc&1&{
z*ECnCnQCH4A|1{xu$*`uBMWtmeve3w^Y~r*0Hb7e>Tw=7W
zK*J+Ok6Em+cp_m{!c&1n#d0ivT_Bn->yvko+x0D5s~fuGm>!q@VhspgDonm_MC3dnrbb!H*0Eu>eam$^5}uJ>
zce|cpZU?nwX1&byRAi79$Og5~HkPoa;yGS$z)KZnR0PJuu^F-Jm5Oz|R`CWE2^%Ul
z*-}MC#ak9z7t**d(G4eg-#9W29z8UTh@T6rfA9EaOCZ7prUn;fx!OCvIl5<4Z_&^*
z`70g40vz+0`b_2vmls3@hlv;07Ik?qVY?5s(6F6s9O_>14E_&5jLw7zNNrBAiL%U_
z8pg^ty|y7vc3jWr+r%8k>4EbX0ga9<$qCXlIt88aVjtpX;Ledu1V#mugw;U+rZ7#K
zjBA*oBAomKQN-xnJVj*x1kpZXwZ$IdJEutOFZChqo*-H3LGD2rpwtMdBQ!=R>^zTT
z&@+WGqM61lQC*;JCFHP1d^U&$vnmcclm9wtDe~RGO=6nC3U1*xF`PvKcW{?D&QU~+
MeDm}#5RTy9Ki%`+-2eap
literal 0
HcmV?d00001
diff --git a/001003/out/production/001003/WordCount/Word.class b/001003/out/production/001003/WordCount/Word.class
new file mode 100644
index 0000000000000000000000000000000000000000..ed46273a5bc508c7278e3e05e0f5ba231e7dd091
GIT binary patch
literal 4790
zcmbtYd3aRS760AY-pu3yA&|gGf-FI@5{Nd)B&I+F35JM(ULS$yIT6}bRxB@T_KoEWbBMWxw|=HCz35a
zT;f)wFR?3S*du9Eq4uopj)}TDc_h@4NG0q}h03~#0`;5dN|!ZAbyIp0DYJKEsNYO)
zF#3~Rspzo=jN~RGosf5LF<|dbIKFMR(t};rNXl-JnfNxa+ekYr3e)TACmK`GM1(dJ
zRJVe!Kdms+l}lJHD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34_aGcC>5~lF)bd=-GT&Z#oV>wpv4XAXC@`}Jpba78i9OqL`
zU*hjLi4gT`4G$xjMR;9P7LhHTzPm81ru^J{5veJ^J{SHha7=c)L43$1?KA)wyFryR
z2G>D2EZ)O?nFgnbKp469m5}gCMRh#jZwoe!p-v$liiO5d
zuW$#p%B(?AabsMoIp9BYCqjpCaZDRSldM*gmz+1td|o^f3seSkP%k3Xu`q{<7MVq|
zSj<}NI}oHV2R)%!z~3qoOE_>d9tt?D4<5wAoJ2?t2Ur0`at`gEiG`%J15Ro0VamW%
zgjt?5Se$iOi&oa*3WuNTaShi^Y(Rz$Y(F;P7AEjkY~gPPTX7$@;Q?HQBV_v{xSHRs
zufgBYj~6k3moTUzFx52dR7?0=N+t^-Zf9>>&jzrCGziezQtA8}N}WDcho+oQB0wRRgG
za%=?Y*%IucjS#&8=Fq-tAwj*awmsw8_EMWPt>uWkf~bb1dKqmjz|*KXjo=wlTw@t>
zUBeKIaU(w|;ANbv!TK+jzk+iptWHyIyvvnG<#MJ4>Dp_l-^XVaN#+uwAvejQ^)PpQ
zPNw8Kk!vJ>8&n}pOyo}$Bk$+FA2#277=giO1!s-?#b-w-!o0kQzw@`EJGrh?@{^SP
J6h4j5{14zwt}6fl
literal 0
HcmV?d00001
diff --git a/001003/out/production/001003/input.txt b/001003/out/production/001003/input.txt
new file mode 100644
index 0000000..59cc749
--- /dev/null
+++ b/001003/out/production/001003/input.txt
@@ -0,0 +1,3 @@
+ Today, people's lifestyle pace is very fast and a lot of young people feel the great pressure when they come to the job market. Before I graduated from college, I started to come to the job market. It was hard for me to get the job I wanted. I got rejected many times, but when the moment I was hired, I felt the victory.
+ I still remembered the day when I was interviewed. Before I came to the company, I had practised many times and my friends pretended to be the employers, asking me all kinds of questions. So I made some preparations and believed that I wouldn't lose control. At the beginning, the employers asked me some simple questions, which I had prepared, so I felt confident.But when they asked me about the company, I forgot to search enough information. But I told myself to calm down,so I expressed my wish to work here. Two days later, I was informed that I got the job. My heart was beating very fast,just liked I had conquered the world.
+ The experience of being success helps me to be stronger and gain more confidence.
\ No newline at end of file
diff --git a/001003/result.txt b/001003/result.txt
new file mode 100644
index 0000000..e69de29
diff --git a/001003/src/WordCount/FileFunction.java b/001003/src/WordCount/FileFunction.java
new file mode 100644
index 0000000..30dcaed
--- /dev/null
+++ b/001003/src/WordCount/FileFunction.java
@@ -0,0 +1,45 @@
+package WordCount;
+
+import java.io.*;
+
+/**
+ * Created by zhangyilin on 2018/9/27.
+ */
+public class FileFunction {
+
+ public BufferedReader ReadFromFile(String path) throws IOException{
+ //读取文件
+
+ File file = new File(path);
+ if (!file.exists() || file.isDirectory()) {
+ System.out.println("请输入正确文件名!");
+ throw new FileNotFoundException();
+ }
+
+ InputStreamReader isr = new InputStreamReader(new FileInputStream(path));// 建立一个输入流对象
+ BufferedReader br = new BufferedReader(isr);
+
+
+// FileInputStream fis = new FileInputStream(file);
+// byte[] buf = new byte[1024];
+// StringBuffer sb = new StringBuffer();
+// while ((fis.read(buf)) != -1) {
+// sb.append(new String(buf));
+// buf = new byte[1024];// 重新生成,避免和上次读取的数据重复
+// }
+// return sb.toString();
+ return br;
+ }
+
+
+ public void WriteToFile(String path, String content) throws Exception {
+ //写入文件
+ try {
+ OutputStream out = new FileOutputStream(path);
+ out.write(content.getBytes());
+ out.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/001003/src/WordCount/Main.java b/001003/src/WordCount/Main.java
new file mode 100644
index 0000000..01c9cfb
--- /dev/null
+++ b/001003/src/WordCount/Main.java
@@ -0,0 +1,23 @@
+package WordCount;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Scanner;
+
+/**
+ * Created by zhangyilin on 2018/9/27.
+ */
+public class Main {
+ public static void main(String[] args) throws Exception {
+ Scanner input = new Scanner(System.in);
+ String file = input.next();
+// FileFunction fileFunction = new FileFunction();
+ Word word = new Word(file);
+// String charNum =word.charCount();
+ System.out.println(word.charCount());
+ System.out.println(word.wordCount());
+ System.out.println(word.lineCount());
+ System.out.println(word.sortWord());
+// System.out.println(word.lists);
+ }
+}
diff --git a/001003/src/WordCount/Word.java b/001003/src/WordCount/Word.java
new file mode 100644
index 0000000..2739c2e
--- /dev/null
+++ b/001003/src/WordCount/Word.java
@@ -0,0 +1,107 @@
+package WordCount;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.util.*;
+
+/**
+ * Created by zhangyilin on 2018/9/27.
+ */
+public class Word {
+ String path;
+ private List lists = new ArrayList<>();
+ public Word(String path) {
+ this.path = path;
+ }
+
+ public String charCount() throws Exception {//统计字符
+ int charNum = 0;
+// InputStreamReader isr = new InputStreamReader(new FileInputStream(path));// 建立一个输入流对象
+// BufferedReader br = new BufferedReader(isr);
+ BufferedReader br = new FileFunction().ReadFromFile(path);
+ int getchar;
+ while ((getchar = br.read()) != -1) {
+ //忽略汉字,换行也算字符(ascii码为10),数字字母符号的ascii码在32-126
+ if (getchar > 31 && getchar < 127 || getchar == 10) {
+ charNum++;
+ }
+ }
+ return "characters: " + charNum;
+ }
+
+ public String wordCount()throws Exception{//统计单词总数
+ int wordsNum = 0;//单词总数
+ BufferedReader br = new FileFunction().ReadFromFile(path);
+ String str = br.readLine();
+ while (str != null) {//统计有效行的字符
+ String wordsArr[] = str.split("\\s*[^0-9a-zA-Z]+");//根据分隔符为数字字母以外的存放在数组//"\\w+"
+ for (String word : wordsArr) {
+ //以4个英文字母开头,跟上字母数字符号
+ if (word.matches("[a-zA-Z]{4,}[a-zA-Z0-9]*")) {
+ lists.add(word);
+ }
+ }
+ str = br.readLine();
+ }
+ wordsNum = lists.size();
+
+ return "words:" + wordsNum;
+ }
+
+
+
+ public String lineCount()throws Exception{//统计行
+ int lineNum = 0;
+// InputStreamReader isr = new InputStreamReader(new FileInputStream(path));// 建立一个输入流对象
+// BufferedReader br = new BufferedReader(isr);
+ BufferedReader br = new FileFunction().ReadFromFile(path);
+ String str = br.readLine();
+ while (str != null) {//统计有效行的字符
+ lineNum++;
+ str = br.readLine();
+ }
+
+ return "lines:" + lineNum;
+ }
+
+
+ public String sortWord() throws Exception{//单词排序前十
+ Map treeMap = new TreeMap();
+
+ for (int i = 0; i < lists.size(); i++) {
+ String s = lists.get(i).toLowerCase();//忽略大小写
+ if (!treeMap.containsKey(s)) {
+ //不存在
+ treeMap.put(s, 1);
+ } else {
+ //已经存在
+ int n = treeMap.get(s);
+ treeMap.put(s, n + 1);
+ }
+ }
+
+ List> list = new ArrayList>(treeMap.entrySet());
+ Collections.sort(list, ((o1, o2) -> o2.getValue().compareTo(o1.getValue())));
+ int n = 10;
+ String s[] = new String[n];
+
+ int i =0;
+ for (Map.Entry entry : list) {
+ if (n-- == 0)
+ break;
+ String key = entry.getKey();
+ Integer value = entry.getValue();
+ s[i] = "<" + key + ">:" + value;
+// System.out.print("<" + key + ">:" + value);
+// System.out.println(s[i]);
+ i++;
+ }
+ String string = s[0]+"\n";
+ for (int j = 1; j
Date: Fri, 28 Sep 2018 20:07:18 +0800
Subject: [PATCH 02/13] change package
---
001003/.idea/workspace.xml | 202 ++++++++++++------
.../001003/{WordCount => }/FileFunction.class | Bin 1687 -> 1667 bytes
001003/out/production/001003/Main.class | Bin 0 -> 977 bytes
.../001003/{WordCount => }/Word.class | Bin 4790 -> 4760 bytes
.../production/001003/WordCount/Main.class | Bin 1017 -> 0 bytes
001003/result.txt | 0
001003/src/{WordCount => }/FileFunction.java | 8 +-
001003/src/{WordCount => }/Main.java | 6 +-
001003/src/{WordCount => }/Word.java | 5 +-
9 files changed, 141 insertions(+), 80 deletions(-)
rename 001003/out/production/001003/{WordCount => }/FileFunction.class (44%)
create mode 100644 001003/out/production/001003/Main.class
rename 001003/out/production/001003/{WordCount => }/Word.class (58%)
delete mode 100644 001003/out/production/001003/WordCount/Main.class
delete mode 100644 001003/result.txt
rename 001003/src/{WordCount => }/FileFunction.java (91%)
rename 001003/src/{WordCount => }/Main.java (84%)
rename 001003/src/{WordCount => }/Word.java (96%)
diff --git a/001003/.idea/workspace.xml b/001003/.idea/workspace.xml
index 64c457a..2f3effa 100644
--- a/001003/.idea/workspace.xml
+++ b/001003/.idea/workspace.xml
@@ -2,7 +2,10 @@
-
+
+
+
+
@@ -15,37 +18,33 @@
-
-
+
+
-
-
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
@@ -81,11 +80,14 @@
-
-
+
+
+
+
+
@@ -116,8 +118,6 @@
-
-
@@ -130,8 +130,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -156,7 +172,7 @@
-
+
@@ -177,6 +193,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -580,12 +611,14 @@
-
+
+
-
-
+
+
+
@@ -600,7 +633,8 @@
1538041097464
-
+
+
1538120947379
@@ -620,7 +654,7 @@
-
+
@@ -629,31 +663,31 @@
+
-
+
-
-
+
+
-
+
-
+
-
@@ -687,13 +721,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
@@ -701,11 +765,7 @@
-
-
-
-
-
+
@@ -736,54 +796,64 @@
-
-
-
-
+
-
-
-
-
-
+
+
+
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/001003/out/production/001003/WordCount/FileFunction.class b/001003/out/production/001003/FileFunction.class
similarity index 44%
rename from 001003/out/production/001003/WordCount/FileFunction.class
rename to 001003/out/production/001003/FileFunction.class
index 9c42a38abb6ee1dc18b67da0ce4734df0d42d945..8af73b3a50a1798f3fcc70ff0eee801a89f1ab54 100644
GIT binary patch
delta 86
zcmbQv+sr#*CljB~#-sC?7z!xjwy7(Qa5C^Qh%@jr
z$TJ8qs51yNm@|klI5NmjE@Yi2sRoo)XAor2U=U@{W{_aeWRPUgVvuFfnXJJU4FK?K
B7Cis}
diff --git a/001003/out/production/001003/Main.class b/001003/out/production/001003/Main.class
new file mode 100644
index 0000000000000000000000000000000000000000..06788813bf3bb263771c2393f48f453c8a091262
GIT binary patch
literal 977
zcmZuvYflqV5IwiA?QR!oc?rG&A8nzmB8u9ILWRVnph*pe_-VVW<&y1gv)wBGA-~Iq
zHj%_1;EyuS>^3b5O*%7o9_O4pcYpu+`3t}rb~KFRo`U--9w4tFh60@|oW|hrj1#1eP2&5{~mBEHUJYU!sNL0N;TVT8CM%^-9*Y+9uvy5b10H)ek&p%`tAIVd%wtZsR?Lc~NN5NA%*S)T9**hVE
z%34<#MMoAnfn11qo=(BKj%Rqz4KH+*Q6Ub-=EO@K8+fJTH7W`=b!>5_ii(amY_`K@
z<`Bq^w7zQ`+ZJDLlp2csr?LL66WA?*7z0d4tB{`YmUly&w9OV>a5jHwAzZO*pAgSf
zzHspg2yig?|HH&R-u#H}Jw4foPPL9qzv^|};RQ(1xfTJX%>xceR{1Rky{bcB(I8HD
zJU`$aVjfrM!{uKLbamv&PSD99FUTj0eTW}nd6H}@Or|hJu^u&G8Z&fKaTT)!!o%MY
zM}qv;8Da;gi1(4GE%lJxJwxhXxesOU6zNhAY7bfzWrmSHjK(M$F)tuZh-qYqDNA+^
zV^}2dC6d2RnN4D5RmF&z>euL$q1tuaAf;KX;wEm9!Z{Rh8+Sz>%
literal 0
HcmV?d00001
diff --git a/001003/out/production/001003/WordCount/Word.class b/001003/out/production/001003/Word.class
similarity index 58%
rename from 001003/out/production/001003/WordCount/Word.class
rename to 001003/out/production/001003/Word.class
index ed46273a5bc508c7278e3e05e0f5ba231e7dd091..838d6b750627b0dfe833613c09d36ce8c55072af 100644
GIT binary patch
delta 271
zcmWNK%Su9F6h_y!qjWiTG_x#`EISq5zzXb!5TOwmm_^x*ZX5?qn+A;nr*S4dL8A)c
zhX&CDL=VxdQ4l0JZ%_8#d>?DCSNFkfyhtEaGH()W6We@R_ac_5g}#H~E-X56u<0f2
zSM7Q{LVy@i;w0&3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ap
diff --git a/001003/result.txt b/001003/result.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/001003/src/WordCount/FileFunction.java b/001003/src/FileFunction.java
similarity index 91%
rename from 001003/src/WordCount/FileFunction.java
rename to 001003/src/FileFunction.java
index 30dcaed..9662d90 100644
--- a/001003/src/WordCount/FileFunction.java
+++ b/001003/src/FileFunction.java
@@ -1,19 +1,17 @@
-package WordCount;
-
import java.io.*;
/**
- * Created by zhangyilin on 2018/9/27.
+ * Created by zhangyilin on 2018/9/28.
*/
public class FileFunction {
- public BufferedReader ReadFromFile(String path) throws IOException{
+ public BufferedReader ReadFromFile(String path) throws IOException {
//读取文件
File file = new File(path);
if (!file.exists() || file.isDirectory()) {
System.out.println("请输入正确文件名!");
- throw new FileNotFoundException();
+ throw new FileNotFoundException();
}
InputStreamReader isr = new InputStreamReader(new FileInputStream(path));// 建立一个输入流对象
diff --git a/001003/src/WordCount/Main.java b/001003/src/Main.java
similarity index 84%
rename from 001003/src/WordCount/Main.java
rename to 001003/src/Main.java
index 01c9cfb..6a80972 100644
--- a/001003/src/WordCount/Main.java
+++ b/001003/src/Main.java
@@ -1,11 +1,7 @@
-package WordCount;
-
-import java.io.File;
-import java.io.IOException;
import java.util.Scanner;
/**
- * Created by zhangyilin on 2018/9/27.
+ * Created by zhangyilin on 2018/9/28.
*/
public class Main {
public static void main(String[] args) throws Exception {
diff --git a/001003/src/WordCount/Word.java b/001003/src/Word.java
similarity index 96%
rename from 001003/src/WordCount/Word.java
rename to 001003/src/Word.java
index 2739c2e..ae32f31 100644
--- a/001003/src/WordCount/Word.java
+++ b/001003/src/Word.java
@@ -1,12 +1,9 @@
-package WordCount;
import java.io.BufferedReader;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
import java.util.*;
/**
- * Created by zhangyilin on 2018/9/27.
+ * Created by zhangyilin on 2018/9/28.
*/
public class Word {
String path;
--
Gitee
From 20ec9e5b1ae8bf32660d6dc35f1331e08765b42b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=80=E4=B8=AA0010?= <1357146670@qq.com>
Date: Sat, 29 Sep 2018 22:10:18 +0800
Subject: [PATCH 03/13] =?UTF-8?q?=E7=94=9F=E6=88=90jar=E5=8C=85=E6=B5=8B?=
=?UTF-8?q?=E8=AF=95=E4=B8=80=E4=B8=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
001003/001003.jar | Bin 0 -> 6204 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 001003/001003.jar
diff --git a/001003/001003.jar b/001003/001003.jar
new file mode 100644
index 0000000000000000000000000000000000000000..2dba220e475999acc2df436295bd80707ae10063
GIT binary patch
literal 6204
zcmZ{o1yodDx4;LG?vU=3?gkO*7`i(|8YG4iap(|+?hpovp%f4VLAq1AYle_c38{xK
zKK;M#TL|jHq)09b#L1_J&P62Kz>P(e?YTSY^W7bvTt
zqNt#{*Qn8vp=KfkT7pYTP_yxN6)SBSWLLI((CYs~ac4p`i)Thzb`^y$+z-ztOJ|
zprwY65r{0g#qnU7^WoL{mp`s=QvdLW^|0${=LK@{=JEFPRvS^~QdQ?s;pV8<;S=Jk
zUgsF)Rb{Ui5aQb$=pRz!t{2#>VINf@US1$Q
zQ+Fx_lDi&@*YM%Z9W%$|G|%V>R^g)bXS!G*UAcA-)%{|SuEWf(%Gb(T=gQviQYT=)
z=MS=jf{($F*N}p4+M%_4Mf3SAP6kY1KYj2LyQ(O6F!MC`H1{xe>*8%t3;rs(2uK~F
z4@s6_G&1O97j8~#b8KFY6!p%LjX+dD!aPma#7a7~@^1S)n_;#X?jAWa{Lol;1PzUN
zMH$0rb+Iinnb`71Lmz>Ron*b#FadD*qo9NRQj8V(z#ODcw0^LIGi!sxSkbG>&R_;O
zYH(epoh-U9(P_owY^YGbW;E`TYlnt_@^KoEE*bblgzFuoT?J=WWsMkorI%iqGs!#5
za1qUQbaBJd)FV;!3!8Q-ZiWfm;mg}+2X(arDg_dxoo1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TwvTi+gv3pqcJwA)U<_*O0t2|PWCjPM3
zmulA*cPWd}Up!=F8tJsIe(1{X>GU2O$D!}DHlW$UCW0H|)2K7lglC$7d|gBJ^XU_(
zIpWBtQYI!&oo0r%<{7)^bvY6Kx!7KE+@IR_3qFp{uAYxCEQvG-|GH^#?Nl12esw*u
z>cj1=`|&@M9`>3kC$pTdd?N%LNZhny>v_?~rhmLA
zL_RPfF9Ufib}GBcCSw%57XQh{tSzUln1{Kj^a2_WyQsjQ7{oDiIkoHvW`7?+Yp^Eb
zahJ5yKf}Fz$iN?(^|v15gWlhX{HGq%Lwf&QZM4)-AD9^cfcEg%
NJw(+0kazKLB+|Kpy}A
literal 0
HcmV?d00001
--
Gitee
From bc75131b29d7cd77d54484c20cbb8e33c3402c38 Mon Sep 17 00:00:00 2001
From: jmuLWX <1126676219@qq.com>
Date: Sat, 29 Sep 2018 22:41:14 +0800
Subject: [PATCH 04/13] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20gui/.keep?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
001003/gui/.keep | 0
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 001003/gui/.keep
diff --git a/001003/gui/.keep b/001003/gui/.keep
new file mode 100644
index 0000000..e69de29
--
Gitee
From 2f9491f92ee107e1541cb63cbccaa448764cd233 Mon Sep 17 00:00:00 2001
From: jmuLWX <1126676219@qq.com>
Date: Sat, 29 Sep 2018 22:41:59 +0800
Subject: [PATCH 05/13] Upload NewJFrame.java
---
001003/gui/NewJFrame.java | 138 ++++++++++++++++++++++++++++++++++++++
1 file changed, 138 insertions(+)
create mode 100644 001003/gui/NewJFrame.java
diff --git a/001003/gui/NewJFrame.java b/001003/gui/NewJFrame.java
new file mode 100644
index 0000000..9ed67b1
--- /dev/null
+++ b/001003/gui/NewJFrame.java
@@ -0,0 +1,138 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package wordcount;
+
+/**
+ *
+ * @author Administrator
+ */
+public class NewJFrame extends javax.swing.JFrame {
+
+ /**
+ * Creates new form NewJFrame
+ */
+ public NewJFrame() {
+ initComponents();
+ }
+
+ /**
+ * This method is called from within the constructor to initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is always
+ * regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jScrollPane1 = new javax.swing.JScrollPane();
+ jTextArea1 = new javax.swing.JTextArea();
+ jLabel1 = new javax.swing.JLabel();
+ jLabel2 = new javax.swing.JLabel();
+ jTextField1 = new javax.swing.JTextField();
+ jButton1 = new javax.swing.JButton();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+
+ jTextArea1.setColumns(20);
+ jTextArea1.setRows(5);
+ jScrollPane1.setViewportView(jTextArea1);
+
+ jLabel1.setText("词频统计结果如下:");
+
+ jLabel2.setText("请输入文件名:");
+
+ jTextField1.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jTextField1ActionPerformed(evt);
+ }
+ });
+
+ jButton1.setText("统计词频");
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGap(32, 32, 32)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 471, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(85, 85, 85)
+ .addComponent(jButton1)))
+ .addContainerGap(76, Short.MAX_VALUE))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGap(48, 48, 48)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jButton1))
+ .addGap(30, 30, 30)
+ .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(18, 18, 18)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(86, Short.MAX_VALUE))
+ );
+
+ pack();
+ }// //GEN-END:initComponents
+
+ private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
+ // TODO add your handling code here:
+ }//GEN-LAST:event_jTextField1ActionPerformed
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String args[]) {
+ /* Set the Nimbus look and feel */
+ //
+ /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
+ * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
+ */
+ try {
+ for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
+ if ("Nimbus".equals(info.getName())) {
+ javax.swing.UIManager.setLookAndFeel(info.getClassName());
+ break;
+ }
+ }
+ } catch (ClassNotFoundException ex) {
+ java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (InstantiationException ex) {
+ java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (IllegalAccessException ex) {
+ java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (javax.swing.UnsupportedLookAndFeelException ex) {
+ java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ }
+ //
+
+ /* Create and display the form */
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ new NewJFrame().setVisible(true);
+ }
+ });
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton jButton1;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jLabel2;
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JTextArea jTextArea1;
+ private javax.swing.JTextField jTextField1;
+ // End of variables declaration//GEN-END:variables
+}
--
Gitee
From b014c8585387b3c47a800d5fe4f60f5356d997e9 Mon Sep 17 00:00:00 2001
From: jmuLWX <1126676219@qq.com>
Date: Sat, 6 Oct 2018 17:50:21 +0800
Subject: [PATCH 06/13] =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
=?UTF-8?q?=E5=86=99=E5=85=A5=E6=93=8D=E4=BD=9C=E7=9A=84=E5=8D=95=E5=85=83?=
=?UTF-8?q?=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
001003/FileFunctionTest.class | Bin 0 -> 1120 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 001003/FileFunctionTest.class
diff --git a/001003/FileFunctionTest.class b/001003/FileFunctionTest.class
new file mode 100644
index 0000000000000000000000000000000000000000..fcc51e984b56ed230ef3f119de3d485108bb3337
GIT binary patch
literal 1120
zcmZWnZBG+H5Pr6;TzecX9u!5Y7Ex&na=zee(FBYnCRGeH5Q$%wcA-nIclB=1;LkEq
zFq-%S{87f)yILxI=;>(UkLk=Ihv_nIP91~QaAzQER5zr
z2o^42grU%oo_HH|_e9X-d#+%x8-9zs+dPmu?k6*BHG_z3%T#vbuh`?Nqs=}?oxYbgdnX`2n!fhhz`cL=#_KY$
zH;V@}-H%k?q%0m%cSpFcUzTOwE$czrxyKfs;3>oC&{T%`VLg50&hyc14UG{KHn;pJ
zXo+M6if1=vNvlDbb}vo)&*(=BNT-fyS1FUD*BZsTHeNe{S^Ej={R#5lQ20W*6fV-4
zk2`Y6z(j$1Y|2?l4<;~45m2OgX-v^8LzPRIrq>9)uF$Pf-qEZS-IMlAqxKbrg=1W`
zXOA)W9rI_A#%NNWCKqC)sid!ulqN=ZuoR;^|6$%ehxvi#Xv~s*Kf$z@kMU@LPQl#H
iDYi|_i68Y8F-A&eNQG9K;FkvY(|8u+Gt{Y?!pdI;7W2LU
literal 0
HcmV?d00001
--
Gitee
From c2a886be4c892c7d8585a4f16d8822502448de53 Mon Sep 17 00:00:00 2001
From: jmuLWX <1126676219@qq.com>
Date: Sat, 6 Oct 2018 17:50:53 +0800
Subject: [PATCH 07/13] =?UTF-8?q?=E8=AF=8D=E7=BB=84=E6=93=8D=E4=BD=9C?=
=?UTF-8?q?=E4=B8=8E=E8=87=AA=E5=AE=9A=E4=B9=89=E8=BE=93=E5=87=BA=E7=9A=84?=
=?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
001003/WordTest.class | Bin 0 -> 1145 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 001003/WordTest.class
diff --git a/001003/WordTest.class b/001003/WordTest.class
new file mode 100644
index 0000000000000000000000000000000000000000..602d1c1a3ff210e3e63367ba8effd63cf4ab12e3
GIT binary patch
literal 1145
zcmah|YfsZq7=F%H)~)NfbfO}l6EAE7nOwX9a*1L>vZ;|}MB|sTHCu7CvprS(;1BT^
z_}N5(XyOm>KWTj5t~d-Pe&{*xd2i42Ui#zL*Y5xpu&yE|klc2?M%D7A3PoUW*L-7^
z+NRSiJ=xi{>QX>?OAZ2wGCMAjuxvZFToH)p3pFx7a2u9}IMO;)BvoWc$F4~X2&8PM
z6UZ64FE!{GVi!YTIA8AJY)Q{{noEUR3Ib^zc~x_#Z3!4df#vhPZ8e-wTFlLAr?t6iEAZHn&A5)dib;XozX`4TzU76abret((9KY@@j5Wu
z)TGIiP45nO=>*M4!y}FR(&L8rdKJxxCQGI{O3gj?T~G3$xd}IQ%yJWwJ>@)ZsaW`H
zrMhW!+{PX1SKD%$vK8*pCRcY)$0B%uUEWnMpaClR7feYw^lb`cwxn5qRWUo!0%%)q
z;MJ{1Hm^vA+3;Lum^pH^PjT9GK_4v@o&2I5B~6N?hfqSBQ9OiJ{09BG(SL}+FUWo(
zYYfA5_J=WjBweJNab8j`MmCC{kxd-n
zQrWmtnVLSrwH}T^vFx1!ca#1UWJ0W5H!{Lv`xK@rw@wH*NQzO^%zyCTNB9%!GBX%G
zK&f&p9ANGPROKU-_z~_hpLkezm(L(Y4j~PLHavTR&qTy0Mm=7}ed3cQ4Ks^jg>s}3
S`-yR(Vt$RrhE-C
Date: Sat, 6 Oct 2018 17:59:12 +0800
Subject: [PATCH 08/13] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B600100?=
=?UTF-8?q?3/FileFunctionTest.class?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
001003/FileFunctionTest.class | Bin 1120 -> 0 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 001003/FileFunctionTest.class
diff --git a/001003/FileFunctionTest.class b/001003/FileFunctionTest.class
deleted file mode 100644
index fcc51e984b56ed230ef3f119de3d485108bb3337..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1120
zcmZWnZBG+H5Pr6;TzecX9u!5Y7Ex&na=zee(FBYnCRGeH5Q$%wcA-nIclB=1;LkEq
zFq-%S{87f)yILxI=;>(UkLk=Ihv_nIP91~QaAzQER5zr
z2o^42grU%oo_HH|_e9X-d#+%x8-9zs+dPmu?k6*BHG_z3%T#vbuh`?Nqs=}?oxYbgdnX`2n!fhhz`cL=#_KY$
zH;V@}-H%k?q%0m%cSpFcUzTOwE$czrxyKfs;3>oC&{T%`VLg50&hyc14UG{KHn;pJ
zXo+M6if1=vNvlDbb}vo)&*(=BNT-fyS1FUD*BZsTHeNe{S^Ej={R#5lQ20W*6fV-4
zk2`Y6z(j$1Y|2?l4<;~45m2OgX-v^8LzPRIrq>9)uF$Pf-qEZS-IMlAqxKbrg=1W`
zXOA)W9rI_A#%NNWCKqC)sid!ulqN=ZuoR;^|6$%ehxvi#Xv~s*Kf$z@kMU@LPQl#H
iDYi|_i68Y8F-A&eNQG9K;FkvY(|8u+Gt{Y?!pdI;7W2LU
--
Gitee
From dd7838a2dadceba1c15e6b448d9060fc8066639f Mon Sep 17 00:00:00 2001
From: jmuLWX <1126676219@qq.com>
Date: Sat, 6 Oct 2018 17:59:26 +0800
Subject: [PATCH 09/13] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B600100?=
=?UTF-8?q?3/WordTest.class?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
001003/WordTest.class | Bin 1145 -> 0 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 001003/WordTest.class
diff --git a/001003/WordTest.class b/001003/WordTest.class
deleted file mode 100644
index 602d1c1a3ff210e3e63367ba8effd63cf4ab12e3..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1145
zcmah|YfsZq7=F%H)~)NfbfO}l6EAE7nOwX9a*1L>vZ;|}MB|sTHCu7CvprS(;1BT^
z_}N5(XyOm>KWTj5t~d-Pe&{*xd2i42Ui#zL*Y5xpu&yE|klc2?M%D7A3PoUW*L-7^
z+NRSiJ=xi{>QX>?OAZ2wGCMAjuxvZFToH)p3pFx7a2u9}IMO;)BvoWc$F4~X2&8PM
z6UZ64FE!{GVi!YTIA8AJY)Q{{noEUR3Ib^zc~x_#Z3!4df#vhPZ8e-wTFlLAr?t6iEAZHn&A5)dib;XozX`4TzU76abret((9KY@@j5Wu
z)TGIiP45nO=>*M4!y}FR(&L8rdKJxxCQGI{O3gj?T~G3$xd}IQ%yJWwJ>@)ZsaW`H
zrMhW!+{PX1SKD%$vK8*pCRcY)$0B%uUEWnMpaClR7feYw^lb`cwxn5qRWUo!0%%)q
z;MJ{1Hm^vA+3;Lum^pH^PjT9GK_4v@o&2I5B~6N?hfqSBQ9OiJ{09BG(SL}+FUWo(
zYYfA5_J=WjBweJNab8j`MmCC{kxd-n
zQrWmtnVLSrwH}T^vFx1!ca#1UWJ0W5H!{Lv`xK@rw@wH*NQzO^%zyCTNB9%!GBX%G
zK&f&p9ANGPROKU-_z~_hpLkezm(L(Y4j~PLHavTR&qTy0Mm=7}ed3cQ4Ks^jg>s}3
S`-yR(Vt$RrhE-C
Date: Sat, 6 Oct 2018 17:59:55 +0800
Subject: [PATCH 10/13] =?UTF-8?q?=E8=AF=BB=E5=8F=96=E6=96=87=E4=BB=B6?=
=?UTF-8?q?=E4=B8=8E=E5=86=99=E5=87=BA=E6=96=87=E4=BB=B6=E6=93=8D=E4=BD=9C?=
=?UTF-8?q?=E7=9A=84=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
001003/FileFunctionTest.java | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
create mode 100644 001003/FileFunctionTest.java
diff --git a/001003/FileFunctionTest.java b/001003/FileFunctionTest.java
new file mode 100644
index 0000000..3cb372c
--- /dev/null
+++ b/001003/FileFunctionTest.java
@@ -0,0 +1,25 @@
+import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+
+import org.junit.jupiter.api.Test;
+
+class FileFunctionTest {
+ FileFunction fi=new FileFunction();
+ @Test
+ void testReadFromFile() throws IOException {
+ String path="input.txt";
+ assertTrue(fi.ReadFromFile(path).equals("Monday Tuesday Wednesday Thursday"));
+ }
+
+
+ @Test
+ void testWriteToFile() throws Exception {
+ String outpath="output.txt";
+ fi.WriteToFile(outpath, "hello i am test");
+ fi.ReadFromFile(outpath).equals( "hello i am test");
+ }
+
+}
--
Gitee
From e311d1d20565db22590dc2643d668312cfed0f91 Mon Sep 17 00:00:00 2001
From: jmuLWX <1126676219@qq.com>
Date: Sat, 6 Oct 2018 18:00:31 +0800
Subject: [PATCH 11/13] =?UTF-8?q?=E8=AF=8D=E7=BB=84=E6=93=8D=E4=BD=9C?=
=?UTF-8?q?=E7=9A=84=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
001003/WordTest.java | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
create mode 100644 001003/WordTest.java
diff --git a/001003/WordTest.java b/001003/WordTest.java
new file mode 100644
index 0000000..61ec875
--- /dev/null
+++ b/001003/WordTest.java
@@ -0,0 +1,20 @@
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
+class WordTest {
+ Word word=new Word("input.txt");
+ @Test
+ void testPhrase() throws Exception {
+ String str=word.Phrase(3);
+ String str2="Monday Tuesday Wednesday: 1"+"\n"+
+ " Tuesday Wednesday Thursday: 1";
+ assertEquals(str,str2);
+ }
+ @Test
+ void testsortWord() throws Exception {
+ int n=4;
+ String str=word.sortWord(n);
+ assertTrue(word.sortWord(n).length()!=0);
+ }
+}
--
Gitee
From 7426ac74a9419e883ece6d862f6e5216f8b38863 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=80=E4=B8=AA0010?= <1357146670@qq.com>
Date: Sun, 7 Oct 2018 17:16:46 +0800
Subject: [PATCH 12/13] =?UTF-8?q?gui=E7=95=8C=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
001003/src/FileFunction.java | 27 ++--
001003/src/Main.java | 240 +++++++++++++++++++++++++++++++++--
001003/src/Word.java | 92 ++++++++++++--
3 files changed, 321 insertions(+), 38 deletions(-)
diff --git a/001003/src/FileFunction.java b/001003/src/FileFunction.java
index 9662d90..8a81aa9 100644
--- a/001003/src/FileFunction.java
+++ b/001003/src/FileFunction.java
@@ -1,11 +1,17 @@
-import java.io.*;
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
/**
- * Created by zhangyilin on 2018/9/28.
+ *
+ * @author zhangyilin
*/
-public class FileFunction {
- public BufferedReader ReadFromFile(String path) throws IOException {
+import java.io.*;
+public class FileFunction {
+ public BufferedReader ReadFromFile(String path) throws IOException {
//读取文件
File file = new File(path);
@@ -17,22 +23,14 @@ public class FileFunction {
InputStreamReader isr = new InputStreamReader(new FileInputStream(path));// 建立一个输入流对象
BufferedReader br = new BufferedReader(isr);
-
-// FileInputStream fis = new FileInputStream(file);
-// byte[] buf = new byte[1024];
-// StringBuffer sb = new StringBuffer();
-// while ((fis.read(buf)) != -1) {
-// sb.append(new String(buf));
-// buf = new byte[1024];// 重新生成,避免和上次读取的数据重复
-// }
-// return sb.toString();
return br;
}
- public void WriteToFile(String path, String content) throws Exception {
+ public void WriteToFile(String path,String content) {
//写入文件
try {
+// String resultFile = "result.txt";
OutputStream out = new FileOutputStream(path);
out.write(content.getBytes());
out.close();
@@ -40,4 +38,5 @@ public class FileFunction {
e.printStackTrace();
}
}
+
}
diff --git a/001003/src/Main.java b/001003/src/Main.java
index 6a80972..0d30529 100644
--- a/001003/src/Main.java
+++ b/001003/src/Main.java
@@ -1,19 +1,233 @@
-import java.util.Scanner;
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
/**
- * Created by zhangyilin on 2018/9/28.
+ *
+ * @author zhangyilin
*/
-public class Main {
- public static void main(String[] args) throws Exception {
- Scanner input = new Scanner(System.in);
- String file = input.next();
-// FileFunction fileFunction = new FileFunction();
+
+import java.util.*;
+import java.io.FileNotFoundException;
+public class Main extends javax.swing.JFrame {
+
+ /**
+ * Creates new form WordCount
+ */
+ public Main(){
+ initComponents();
+ }
+
+ /**
+ * This method is called from within the constructor to initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is always
+ * regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jTextField1 = new javax.swing.JTextField();
+ jTextField2 = new javax.swing.JTextField();
+ jScrollPane1 = new javax.swing.JScrollPane();
+ jTextArea1 = new javax.swing.JTextArea();
+ jButton1 = new javax.swing.JButton();
+ jLabel1 = new javax.swing.JLabel();
+ jLabel2 = new javax.swing.JLabel();
+ jLabel3 = new javax.swing.JLabel();
+ jLabel4 = new javax.swing.JLabel();
+
+ jTextField1.setText("jTextField1");
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+
+ jTextField2.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jTextField2ActionPerformed(evt);
+ }
+ });
+
+ jTextArea1.setColumns(20);
+ jTextArea1.setRows(5);
+ jScrollPane1.setViewportView(jTextArea1);
+
+ jButton1.setText("统计");
+ jButton1.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jButton1ActionPerformed(evt);
+ }
+ });
+
+ jLabel1.setText("-i:设定读入的文件路径");
+
+ jLabel2.setText("-m:设定统计的词组长度");
+
+ jLabel3.setText("-n:设定输出的单词数量");
+
+ jLabel4.setText("-o:设定生成文件的存储路径");
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGap(14, 14, 14)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 368, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGroup(layout.createSequentialGroup()
+ .addGap(12, 12, 12)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(jLabel2)
+ .addGap(18, 18, 18)
+ .addComponent(jLabel4))
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(jLabel1)
+ .addGap(26, 26, 26)
+ .addComponent(jLabel3))))
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 313, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jButton1)))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGap(20, 20, 20)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jButton1))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel1)
+ .addComponent(jLabel3))
+ .addGap(12, 12, 12)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel2)
+ .addComponent(jLabel4))
+ .addGap(36, 36, 36)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+
+ pack();
+ }// //GEN-END:initComponents
+
+ private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed
+ // TODO add your handling code here:
+ }//GEN-LAST:event_jTextField2ActionPerformed
+
+ private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
+ // TODO add your handling code here:
+ String str = jTextField2.getText();
+ String file = null;
+ int numM =0;
+ int numN =0;
+ String resultFile= null;
+ String strarr[] = str.split("\\s+");
+ List list = new ArrayList<>();
+ for (String word:strarr) {
+ list.add(word);
+ }
+// System.out.println(list);
+ for (int i = 0; i
+ /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
+ * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
+ */
+ try {
+ for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
+ if ("Nimbus".equals(info.getName())) {
+ javax.swing.UIManager.setLookAndFeel(info.getClassName());
+ break;
+ }
+ }
+ } catch (ClassNotFoundException ex) {
+ java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (InstantiationException ex) {
+ java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (IllegalAccessException ex) {
+ java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (javax.swing.UnsupportedLookAndFeelException ex) {
+ java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ }
+ //
+ //
+
+ /* Create and display the form */
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ new Main().setVisible(true);
+ }
+ });
}
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton jButton1;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jLabel2;
+ private javax.swing.JLabel jLabel3;
+ private javax.swing.JLabel jLabel4;
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JTextArea jTextArea1;
+ private javax.swing.JTextField jTextField1;
+ private javax.swing.JTextField jTextField2;
+ // End of variables declaration//GEN-END:variables
}
diff --git a/001003/src/Word.java b/001003/src/Word.java
index ae32f31..3719a99 100644
--- a/001003/src/Word.java
+++ b/001003/src/Word.java
@@ -1,11 +1,18 @@
-
-import java.io.BufferedReader;
-import java.util.*;
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
/**
- * Created by zhangyilin on 2018/9/28.
+ *
+ * @author zhangyilin
*/
+
+import java.io.BufferedReader;
+import java.util.*;
public class Word {
+
String path;
private List lists = new ArrayList<>();
public Word(String path) {
@@ -43,7 +50,7 @@ public class Word {
}
wordsNum = lists.size();
- return "words:" + wordsNum;
+ return "words: " + wordsNum;
}
@@ -59,11 +66,63 @@ public class Word {
str = br.readLine();
}
- return "lines:" + lineNum;
+ return "lines: " + lineNum;
}
+ public String Phrase(int number) throws Exception{
- public String sortWord() throws Exception{//单词排序前十
+ if(number>lists.size()){
+ return "the number is too long";
+ }
+ String wordGroup[] = new String[lists.size()-number+1];
+ for (int i = 0; i treeMap =new TreeMap();
+ for (int i = 0; i < wordGroup.length; i++) {
+ String s = wordGroup[i];
+ if (!treeMap.containsKey(s)) {
+ //不存在
+ treeMap.put(s, 1);
+ } else {
+ //已经存在
+ int n = treeMap.get(s);
+ treeMap.put(s, n + 1);
+ }
+ }
+ List> list = new ArrayList>(treeMap.entrySet());
+
+ Collections.sort(list, new Comparator>() {
+ public int compare(Map.Entry o1, Map.Entry o2) {
+ return o2.getValue().compareTo(o1.getValue());
+ }
+ });
+
+// Collections.sort(list, ((o1, o2) -> o2.getValue().compareTo(o1.getValue())));
+ String s[] = new String[wordGroup.length];
+ int i =0;
+ for (Map.Entryentry:list) {
+ String key = entry.getKey();
+ Integer value = entry.getValue();
+ s[i] = key + ": " + value;
+// System.out.println(s[i]);
+ i++;
+ }
+ String string = s[0]+"\n";
+ for (int j = 1; j treeMap = new TreeMap();
for (int i = 0; i < lists.size(); i++) {
@@ -79,13 +138,23 @@ public class Word {
}
List> list = new ArrayList>(treeMap.entrySet());
- Collections.sort(list, ((o1, o2) -> o2.getValue().compareTo(o1.getValue())));
- int n = 10;
- String s[] = new String[n];
+
+ Collections.sort(list, new Comparator>() {
+ public int compare(Map.Entry o1, Map.Entry o2) {
+ return o2.getValue().compareTo(o1.getValue());
+ }
+ });
+
+
+
+
+// Collections.sort(list, ((o1, o2) -> o2.getValue().compareTo(o1.getValue())));
+// int n = 10;
+ String s[] = new String[number];
int i =0;
for (Map.Entry entry : list) {
- if (n-- == 0)
+ if (number-- == 0)
break;
String key = entry.getKey();
Integer value = entry.getValue();
@@ -101,4 +170,5 @@ public class Word {
return string;
}
+
}
--
Gitee
From bebbc168477918ee12137a66f683443c724d547a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=80=E4=B8=AA0010?= <1357146670@qq.com>
Date: Sun, 7 Oct 2018 17:18:58 +0800
Subject: [PATCH 13/13] =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
001003/WordTest.java | 81 +++++++++++++++++++++++++++++++++-----------
1 file changed, 61 insertions(+), 20 deletions(-)
diff --git a/001003/WordTest.java b/001003/WordTest.java
index 61ec875..8457979 100644
--- a/001003/WordTest.java
+++ b/001003/WordTest.java
@@ -1,20 +1,61 @@
-import static org.junit.jupiter.api.Assertions.*;
-
-import org.junit.jupiter.api.Test;
-
-class WordTest {
- Word word=new Word("input.txt");
- @Test
- void testPhrase() throws Exception {
- String str=word.Phrase(3);
- String str2="Monday Tuesday Wednesday: 1"+"\n"+
- " Tuesday Wednesday Thursday: 1";
- assertEquals(str,str2);
- }
- @Test
- void testsortWord() throws Exception {
- int n=4;
- String str=word.sortWord(n);
- assertTrue(word.sortWord(n).length()!=0);
- }
-}
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class WordTest {
+
+
+
+ Word myWord = new Word("input.txt");
+ //input.txt 内的内容为Monday Tuesday Wednesday Thursday
+ @Test
+ public void testCharCount1() throws Exception{
+ //测试字符函数
+ assertEquals("characters: 33",myWord.charCount());
+ }
+ @Test
+ public void testWordCount1() throws Exception{
+ //测试单词函数
+ assertEquals("words: 4",myWord.wordCount());
+ }
+
+
+ @Test
+ public void testLineCount1() throws Exception {
+ //测试文本行数
+ assertEquals("lines: 1",myWord.lineCount());
+ }
+
+ @Test
+ public void PhraseTest1() throws Exception {
+ //当测试数据为文本的单词数
+ myWord.wordCount();
+ assertEquals("Monday Tuesday Wednesday Thursday: 1"+"\n",myWord.Phrase(4));
+ }
+ @Test
+ public void PhraseTest2() throws Exception {
+ //当测试数据大于文本的单词数
+ myWord.wordCount();
+ assertEquals("the number is too long",myWord.Phrase(5));
+ }
+ @Test
+ public void PhraseTest3() throws Exception {
+ //当测试数据小于文本的单词数
+ myWord.wordCount();
+ assertEquals("Monday Tuesday Wednesday: 1" + "\n"+
+ "Tuesday Wednesday Thursday: 1"+"\n",myWord.Phrase(3));
+ }
+
+ @Test
+ public void WordTest1() throws Exception {
+ //输出词频第一的词
+// String path ="input.txt";
+// Word myWord = new Word("input.txt");
+ myWord.wordCount();
+ assertEquals(":1"+"\n",myWord.sortWord(1));
+ }
+
+
+
+
+}
--
Gitee