From 56a666dccef5a4f760b48e7cf2ee1c8ca986d449 Mon Sep 17 00:00:00 2001 From: HolmeC Date: Sun, 16 Sep 2018 11:30:46 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20201621123033/.keep?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 201621123033/.keep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 201621123033/.keep diff --git a/201621123033/.keep b/201621123033/.keep new file mode 100644 index 0000000..e69de29 -- Gitee From 0f6d74319b8eee0129d0ca21a8f7e006551a0a0a Mon Sep 17 00:00:00 2001 From: HolmeC Date: Mon, 17 Sep 2018 13:15:11 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 201621123033/.classpath | 6 ++ 201621123033/.project | 17 +++ .../.settings/org.eclipse.jdt.core.prefs | 11 ++ 201621123033/bin/WordCount/Count$1.class | Bin 0 -> 1484 bytes 201621123033/bin/WordCount/Count.class | Bin 0 -> 3108 bytes 201621123033/bin/WordCount/File.class | Bin 0 -> 3035 bytes 201621123033/bin/WordCount/Main.class | Bin 0 -> 1439 bytes 201621123033/src/WordCount/Count.java | 98 ++++++++++++++++++ 201621123033/src/WordCount/File.java | 57 ++++++++++ 201621123033/src/WordCount/Main.java | 21 ++++ 201621123033/words.txt | 4 + 11 files changed, 214 insertions(+) create mode 100644 201621123033/.classpath create mode 100644 201621123033/.project create mode 100644 201621123033/.settings/org.eclipse.jdt.core.prefs create mode 100644 201621123033/bin/WordCount/Count$1.class create mode 100644 201621123033/bin/WordCount/Count.class create mode 100644 201621123033/bin/WordCount/File.class create mode 100644 201621123033/bin/WordCount/Main.class create mode 100644 201621123033/src/WordCount/Count.java create mode 100644 201621123033/src/WordCount/File.java create mode 100644 201621123033/src/WordCount/Main.java create mode 100644 201621123033/words.txt diff --git a/201621123033/.classpath b/201621123033/.classpath new file mode 100644 index 0000000..63b7e89 --- /dev/null +++ b/201621123033/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/201621123033/.project b/201621123033/.project new file mode 100644 index 0000000..00ef62f --- /dev/null +++ b/201621123033/.project @@ -0,0 +1,17 @@ + + + software + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/201621123033/.settings/org.eclipse.jdt.core.prefs b/201621123033/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..bb35fa0 --- /dev/null +++ b/201621123033/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/201621123033/bin/WordCount/Count$1.class b/201621123033/bin/WordCount/Count$1.class new file mode 100644 index 0000000000000000000000000000000000000000..4973ae9127e022c3bbb202ec9226611dce00be3f GIT binary patch literal 1484 zcmbtUT~pIg5Iwgo4Gn>oPXWIWizF>jil}I@6)VnUEPhNGd=70a!H{&))R~U|#|MWO zAH>lIhi8A3s>ONcX!32)oCY}$O#G(5w1J%+fyXSLGHl&o?gTY-Y>mSg!v z0;`vz+73gk?AFZ$7zPzc=$8>iQb7VKhN#LnBrBFRIP?%_-&7{pL=501FX=h z>U);c2(t-~?)YZI^a{nEM_d)F=>wR?4GGt&!XEq;+{7)0{)XxA73U8Wg*s9+ou406?Ndo}Z=#m7+=7iWpr&+y?gw5!OoTk~H<6ltWBn@-JkTQqK4 zroZRbC9IS4!u?ZFM2W_qySLpY!=$Q*b0Os0@I0eav06SQRCLENy|QhzT4qbab5iQu zq%rh~yMh@KB1%smSSrQuEd8BC=}CY~G(grGBJ>61O!hmJ%nuBGqg4dM+$SO&UBL*g z6~b`uD8}fQW&#tm;~Lo!Op0t@$>RA-*`JtVSP<_on4;xvhGWc+xa z0D)aUq!ckhVMwHVizMD*4pl*8CO9IbL5E=pIYF(2WwIj36P{BGVk@Vy74qFDFG(_& z+93X`6yho@l8f^m%w&%-y+F?q9&i?c5OI-#{>_Akb9*GLwXpcdctYzK3V4cVWQ`Dx NOT|Ca*g!d+_y;P%WUBxG literal 0 HcmV?d00001 diff --git a/201621123033/bin/WordCount/Count.class b/201621123033/bin/WordCount/Count.class new file mode 100644 index 0000000000000000000000000000000000000000..f3070eae58dc96478d87569dcedc7d73260ea9bb GIT binary patch literal 3108 zcmZuzO>i6K8Gb(PN^7mwAla6&a7+pLlVmF~&$lbdGLdHX+wbrF zd*0`LSO5LrKR*R9hSxO&1n!(KJ7@Fds_l+?qXtzVdfr?$M@y!?IC}id`C`EpP)n9w z6o^lIM^)Dren!v|VRyR?<0^Z0|wbnvgs!%krhRL?c8`SH4^- zvB6noo3*ZiOpHmho*RBg+__K3MYvM9D$tj_t@KiJIxb;N!|$2zO-gKPt{AwC=VSqt z9eS5)x9{~&KP3%+mRC&2bjuF?kzT)G;6+)eA*Z-pUL`E-#1(3pZ4+v>w?+^1G?9`! z4@*coG`2PlH2IYC+NVBSt~!O{W0vedeu?dsAqf~$wq11cC9_f~Ry4f2rTevPkpiAg zY-a~l_?-#xVH@O1^HyCP+3;HH2v4aT-Ms1FxC3|c&MKv)?7ivhh^B9%_vCfNKSn>N z1DxLdF$UAaT>qVS6by0frzTL3iU>6rxEpui7o6SWoq4*rzLzU%ZTPgEbA$H%oi5G< z?!yj_^g;B{gAmUyDhHK^H}GuwAL!p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QEiRd>W5)qN`r}0%*+6Xjk)EW=Y|NO7dZ{5k!SiDJy$k{ z7<0$%>{mPbHvZhU4WLM|%feZrW;{jf>Fmz66FAEnW(3Xvab^SnQP49Y95L5~yCaZW zR7CKqhS%^q4}p?-mTkzZAuUSGvm}K$-9_D=QV^22ON!(Zvy!el#0@}4P|iB%l`2TI z3w%+}#O(5O!Bv_#7dW@_Tv(d-@?6*>K-tz_=dq7@&81_amOdU6!}U7z9y?9JJq2Kq zh6`mYYlu6UMG}ur(Oe3&bUtrbshnOa86_28^MsOJSA8vtU7iZOHAo3>dhnM{`1z}H z)WxU5r*GFh0+(rc5aO?x1~i1_uUx>o_+W5eJAT1GqOu_@ubgiw3TSHXQFF>eLiMiah27XRs}V5b=Fx`ean{Ln_P fP?D=MXN?q-pMgJT5D&hD_?wp@Ymv}u{{j6l;sdQBjhuWTDpG(pu6LRg@+Xj;Zn^f!?|7hSdG6 zef;s|(}q*oagTM|*f?ee&Zzsrji5sy^&czSaH?fjnkk4kFK2UihkO zmNU<7TR$n9jvGY+sx-Nw;U;bgL~KLf-l3mBdccQpUDODYQ*fJwy2#wCdK5iK$s*nn z=st(~$1lAmjruh7XFWH2V6 zNW0a_p$uF|`%;!Uk85~{34$Ekrfbxb9`Q-KP$>9fc=Mv$yQJIU(_FUxPQzcg`PG3Y7^tbrUJSJt4bab8aj|IDm! zWu~u^ogw6kAB}Tcud5~fuy5XS?Gqn>OOOT2HFgaEkkC^Hppi>DoZ7x z6)elJ^JU#}3`YU;xir0hLn(MI(0no0RIo4}3#7my;_muiCEK; line=new ArrayList<>(); + Map map=new HashMap(); + public Count(ArrayList line){ + this.line=line; + } + + public int CountChars(){ + int count=0; + for(int i=0;i=4){ + String[] words=str.split("[^a-zA-Z0-9]+"); + for (String word:words){ + int flag=0; + char[] w=word.toCharArray(); + for(int j=0;j<4;j++){ + if(!(('A'<=w[j]&&w[j]<='Z')||('a'<=w[j]&&w[j]<='z'))){ + flag=1; + break; + } + } + if(flag==0){ + if(!map.containsKey(word)){ + count++; + map.put(word, 1); + } + else{ + int num=map.get(word); + map.put(word, ++num); + } + } + } + } + } + return count; + } + + + public int CountLine(){ + int count=0; + for(int i=0;i0){ + count++; + } + } + return count; + } + + public ArrayList WordTop(int count){ + ArrayList> list = new ArrayList>(map.entrySet()); + Collections.sort(list, new Comparator>() { + + @Override + public int compare(Entry o1, Entry o2) { + if (o1.getValue() == o2.getValue()) { + return o1.getKey().compareTo(o2.getKey()); + } + return o2.getValue() - o1.getValue(); + } + + }); + if(count<=10){ + return list; + } + else{ + for(int i=list.size();i>=10;i--){ + list.remove(i); + } + return list; + } + } + +} diff --git a/201621123033/src/WordCount/File.java b/201621123033/src/WordCount/File.java new file mode 100644 index 0000000..2e68024 --- /dev/null +++ b/201621123033/src/WordCount/File.java @@ -0,0 +1,57 @@ +package WordCount; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Map; +import java.util.Map.Entry; + +public class File { + public ArrayList readfile(String file){ + ArrayList arrylist=new ArrayList<>(); + try{ + FileReader fr=new FileReader(file); + BufferedReader br=new BufferedReader(fr); + String str; + while((str=br.readLine())!=null){ + arrylist.add(str); + } + fr.close(); + br.close(); + }catch (IOException e){ + e.printStackTrace(); + } + return arrylist; + } + + + + public void writefile(String path,int CountChars,int CountWords,int CountLine,ArrayList> wordtop){ + try{ + FileWriter fw=new FileWriter(path); + BufferedWriter bw=new BufferedWriter(fw); + String str1="characters:"+CountChars; + String str2="words:"+CountWords; + String str3="lines:"+CountLine; + bw.write(str1); + bw.newLine(); + bw.write(str2); + bw.newLine(); + bw.write(str3); + bw.newLine(); + for(int i=0;i e=wordtop.get(i); + bw.write(e.getKey()+ ":" +e.getValue()); + bw.newLine(); + } + bw.close(); + fw.close(); + }catch (IOException e){ + e.printStackTrace(); + } + } + +} diff --git a/201621123033/src/WordCount/Main.java b/201621123033/src/WordCount/Main.java new file mode 100644 index 0000000..679c83b --- /dev/null +++ b/201621123033/src/WordCount/Main.java @@ -0,0 +1,21 @@ +package WordCount; + +import java.util.ArrayList; +import java.util.Map.Entry; + +public class Main { + public static void main(String[] args){ + String path="D:\\java练习\\software\\words.txt"; + String save="D:\\java练习\\software\\result.txt"; + File file=new File(); + ArrayList line=new ArrayList<>(); + line=file.readfile(path); + Count count=new Count(line); + int CountChars=count.CountChars(); + int CountWords=count.CountWords(); + int CountLine=count.CountLine(); + ArrayList> wordtop=count.WordTop(CountWords); + file.writefile(save, CountChars, CountWords, CountLine, wordtop); + } + +} diff --git a/201621123033/words.txt b/201621123033/words.txt new file mode 100644 index 0000000..4dd2f48 --- /dev/null +++ b/201621123033/words.txt @@ -0,0 +1,4 @@ +file12 hello world file12 88888 +4444 + +hello file12 \ No newline at end of file -- Gitee From 74b1b6268c4aa04c9db5e1ba38134dd0f5fc257b Mon Sep 17 00:00:00 2001 From: HolmeC Date: Mon, 17 Sep 2018 13:17:35 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=A4=8D=E5=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 201621123033/result.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 201621123033/result.txt diff --git a/201621123033/result.txt b/201621123033/result.txt new file mode 100644 index 0000000..98ae812 --- /dev/null +++ b/201621123033/result.txt @@ -0,0 +1,6 @@ +characters:27 +words:3 +lines:3 +file12:3 +hello:2 +world:1 -- Gitee From 6f9030369257dc31d90a629980295943406ae3cc Mon Sep 17 00:00:00 2001 From: HolmeC Date: Sun, 23 Sep 2018 13:10:13 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 201621123033/beauty.txt | 13 +++++++++++++ 201621123033/blank.txt | 0 201621123033/noword.txt | 3 +++ 201621123033/result.txt | 19 +++++++++++++------ 201621123033/test1.txt | 8 ++++++++ 201621123033/test2.txt | 5 +++++ 201621123033/test3.txt | 4 ++++ 7 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 201621123033/beauty.txt create mode 100644 201621123033/blank.txt create mode 100644 201621123033/noword.txt create mode 100644 201621123033/test1.txt create mode 100644 201621123033/test2.txt create mode 100644 201621123033/test3.txt diff --git a/201621123033/beauty.txt b/201621123033/beauty.txt new file mode 100644 index 0000000..10f4db4 --- /dev/null +++ b/201621123033/beauty.txt @@ -0,0 +1,13 @@ +Beauty +There were a sensitivity and a beauty to her that have nothing to do with looks. She was one to be listened to, whose words were so easy to take to heart. +It is said that the true nature of being is veiled. The labor of words, the expression of art, the seemingly ceaseless buzz that is human thought all have in common the need to get at what really is so. The hope to draw close to and possess the truth of being can be a feverish one. In some cases it can even be fatal, if pleasure is one's truth and its attainment more important than life itself. In other lives, though, the search for what is truthful gives life. +I used to find notes left in the collection basket, beautiful notes about my homilies and about the writer's thoughts on the daily scriptural readings. The person who penned the notes would add reflections to my thoughts and would always include some quotes from poets and mystics he or she had read and remembered and loved. The notes fascinated me. Here was someone immersed in a search for truth and beauty. Words had been treasured, words that were beautiful. And I felt as if the words somehow delighted in being discovered, for they were obviously very generous to the as yet anonymous writer of the notes. And now this person was in turn learning the secret of sharing them. Beauty so shines when given away. The only truth that exists is, in that sense, free. +It was a long time before I met the author of the notes. +One Sunday morning, I was told that someone was waiting for me in the office. The young person who answered the rectory door said that it was "the woman who said she left all the notes." When I saw her I was shocked, since I immediately recognized her from church but had no idea that it was she who wrote the notes. She was sitting in a chair in the office with her hands folded in her lap. Her head was bowed and when she raised it to look at me, she could barely smile without pain. Her face was disfigured, and the skin so tight from surgical procedures that smiling or laughing was very difficult for her. She had suffered terribly from treatment to remove the growths that had so marred her face. +We chatted for a while that Sunday morning and agreed to meet for lunch later that week. +As it turned out we went to lunch several times, and she always wore a hat during the meal. I think that treatments of some sort had caused a lot of her hair to fall out. We shared things about our lives. I told her about my schooling and growing up. She told me that she had worked for years for an insurance company. She never mentioned family, and I did not ask. +We spoke of authors we both had read, and it was easy to tell that books are a great love of hers. +I have thought about her often over the years and how she struggled in a society that places an incredible premium on looks, class, wealth and all the other fineries of life. She suffered from a disfigurement that cannot be made to look attractive. I know that her condition hurt her deeply. +Would her life have been different had she been pretty? Chances are it would have. And yet there were a sensitivity and a beauty to her that had nothing to do with looks. She was one to be listened to, whose words were so easy to take to heart. Her words came from a wounded but loving heart, very much like all hearts, but she had more of a need to be aware of it, to live with it and learn from it. She possessed a fine-tuned sense of beauty. Her only fear in life was the loss of a friend. +How long does it take most of us to reach that level of human growth, if we ever get there? We get so consumed and diminished, worrying about all the things that need improving, we can easily forget to cherish those things that last. Friendship, so rare and so good, just needs our care-maybe even the simple gesture of writing a little note now and then, or the dropping of some beautiful words in a basket, in the hope that such beauty will be shared and taken to heart. +The truth of her life was a desire to see beyond the surface for a glimpse of what it is that matters. She found beauty and grace and they befriended her, and showed her what is real. \ No newline at end of file diff --git a/201621123033/blank.txt b/201621123033/blank.txt new file mode 100644 index 0000000..e69de29 diff --git a/201621123033/noword.txt b/201621123033/noword.txt new file mode 100644 index 0000000..7fccc63 --- /dev/null +++ b/201621123033/noword.txt @@ -0,0 +1,3 @@ +hel12 +8888 +4444 777 cc666 \ No newline at end of file diff --git a/201621123033/result.txt b/201621123033/result.txt index 98ae812..cde91f5 100644 --- a/201621123033/result.txt +++ b/201621123033/result.txt @@ -1,6 +1,13 @@ -characters:27 -words:3 -lines:3 -file12:3 -hello:2 -world:1 +characters:3271 +words:276 +lines:13 +that:25 +beauty:8 +notes:8 +words:8 +from:7 +about:6 +life:6 +were:6 +have:5 +truth:5 diff --git a/201621123033/test1.txt b/201621123033/test1.txt new file mode 100644 index 0000000..fe5ab16 --- /dev/null +++ b/201621123033/test1.txt @@ -0,0 +1,8 @@ + +File file File12 File123 + +Hello world File|file\File + +hel +he +h \ No newline at end of file diff --git a/201621123033/test2.txt b/201621123033/test2.txt new file mode 100644 index 0000000..f2aa8ce --- /dev/null +++ b/201621123033/test2.txt @@ -0,0 +1,5 @@ +你好 我是大侦探 + +福尔摩斯 + +的邻居 \ No newline at end of file diff --git a/201621123033/test3.txt b/201621123033/test3.txt new file mode 100644 index 0000000..15e80b4 --- /dev/null +++ b/201621123033/test3.txt @@ -0,0 +1,4 @@ +hello world hello12 file File +hello holmec holmes asuka +asuka asuKa +java python software web zoo animate \ No newline at end of file -- Gitee