From b6abfeef4be114b9fd6c77bb3b260047db09f0be Mon Sep 17 00:00:00 2001 From: IceBloom Date: Mon, 4 Jul 2016 00:30:47 +0800 Subject: [PATCH 1/7] Create ReadMe --- ReadMe | 1 + 1 file changed, 1 insertion(+) create mode 100644 ReadMe diff --git a/ReadMe b/ReadMe new file mode 100644 index 0000000..33ad5f8 --- /dev/null +++ b/ReadMe @@ -0,0 +1 @@ +Hello,My name is ZhaoXin. From cc8a5efe3f7dfe5ea81081324193dd91d82a829a Mon Sep 17 00:00:00 2001 From: Zhaoxin Date: Mon, 4 Jul 2016 18:59:34 +0800 Subject: [PATCH 2/7] EffectiveLines ZhaoXin --- EffectiveLines/.idea/compiler.xml | 22 + .../.idea/copyright/profiles_settings.xml | 3 + .../.idea/libraries/KotlinJavaRuntime.xml | 12 + EffectiveLines/.idea/misc.xml | 26 + EffectiveLines/.idea/modules.xml | 8 + EffectiveLines/.idea/workspace.xml | 477 ++++++++++++++++++ EffectiveLines/EffectiveLines.iml | 12 + .../EffectiveLines/EffectiveLines.class | Bin 0 -> 2031 bytes EffectiveLines/src/EffectiveLines.java | 46 ++ 9 files changed, 606 insertions(+) create mode 100644 EffectiveLines/.idea/compiler.xml create mode 100644 EffectiveLines/.idea/copyright/profiles_settings.xml create mode 100644 EffectiveLines/.idea/libraries/KotlinJavaRuntime.xml create mode 100644 EffectiveLines/.idea/misc.xml create mode 100644 EffectiveLines/.idea/modules.xml create mode 100644 EffectiveLines/.idea/workspace.xml create mode 100644 EffectiveLines/EffectiveLines.iml create mode 100644 EffectiveLines/out/production/EffectiveLines/EffectiveLines.class create mode 100644 EffectiveLines/src/EffectiveLines.java diff --git a/EffectiveLines/.idea/compiler.xml b/EffectiveLines/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/EffectiveLines/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/EffectiveLines/.idea/copyright/profiles_settings.xml b/EffectiveLines/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/EffectiveLines/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/EffectiveLines/.idea/libraries/KotlinJavaRuntime.xml b/EffectiveLines/.idea/libraries/KotlinJavaRuntime.xml new file mode 100644 index 0000000..c630c0b --- /dev/null +++ b/EffectiveLines/.idea/libraries/KotlinJavaRuntime.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/EffectiveLines/.idea/misc.xml b/EffectiveLines/.idea/misc.xml new file mode 100644 index 0000000..c6d8fb7 --- /dev/null +++ b/EffectiveLines/.idea/misc.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/EffectiveLines/.idea/modules.xml b/EffectiveLines/.idea/modules.xml new file mode 100644 index 0000000..79ef913 --- /dev/null +++ b/EffectiveLines/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/EffectiveLines/.idea/workspace.xml b/EffectiveLines/.idea/workspace.xml new file mode 100644 index 0000000..2c48bf4 --- /dev/null +++ b/EffectiveLines/.idea/workspace.xml @@ -0,0 +1,477 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1467295368915 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/EffectiveLines/EffectiveLines.iml b/EffectiveLines/EffectiveLines.iml new file mode 100644 index 0000000..245d342 --- /dev/null +++ b/EffectiveLines/EffectiveLines.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/EffectiveLines/out/production/EffectiveLines/EffectiveLines.class b/EffectiveLines/out/production/EffectiveLines/EffectiveLines.class new file mode 100644 index 0000000000000000000000000000000000000000..f7d05f3a1e8eec36a0c48702a7ce8257e49f0011 GIT binary patch literal 2031 zcma)7Yj+b>6x}zkNz*B9QwmhxDi9teJ^-af6tHNuEss{PAmB8av;)aZoJ>mb#Y2#? zu%EClsr}+ogyj+imLy$tl^@_Q@CP)ZKf;CXI|-6fT+4j8ckVf7pL6a$=brrW@ZNm@ zn{Y9N<=9b$o!F(|%@DlU5k#BZcL(uSi1N4Pp*@6m@UDUmY1tVBlo=u_JvS~ z{c`CJqDNxhlbQo^IVhL+L+HgJxf~AS1Gyhja5RWxL42q{3!x7&DUB=81p?a)({Q#6 zcq3~M2>5ncaY}1D3{&sQruuZdN9#*c67H~KTJnHq8}eKh`kVnHBT(1TmPqI^#~9Ql zF4IasDa|ki7DNtr9M=Z5Xi_u#quq{enEkD8oFomU*Ew2dq7TIcmX}n972Rzl^)AcV zZDq}P+fYnTJBDS-7@FPB=nYQ^L1iYUF@c7Xm#kwXqurF4x=m!2jC#z}QcR)ronQ=s zd9z~D&}(K>0-~Kf*?K0MbOdU;9W8dEQ%k!Xut*9LtO_X>2z6UoJEqHo8G1G;8)Zxt z&*6Cm{VE1v2rPW^_B*piGOpVK%N~4vqd1&@Fm}E$b)|4=q>#ThJvIK|yI%`aqb*TW z#c`Yv2xc?7y)kasDw0U4FkvZ3tM~|XQSUmhyt#@D9GOCv^v?X2pSgdfaN*j_PiKoi zoGISD%wQ5y{O02HWKP8(ECJPZQZ9moGSo>72{e|#CFALdk;2Vy3*$FboWjS_>=PBA zVo1ejGNXiw&ta)JErFhBRK*#b6zT<371?NN?kfzbSmTMYy_{B zWd}6=+a-J1&kpT%EyZRDXz8?W#s!)qC5u^2KSxxqHG$Rry0h1|(z@-O5?KAe(1ZmY z>rt-rBWvgQr$xgfhAR>kP|`B(Bwt74(?W3yc;wrCe9d+>Zp$T)nOoGFL+6nUi77ipI^^^f85ow(DWdO*u`5h|w#?* zCzNqC+sPa>oPqyHp8-pq@3P-+I(ol+P|Bc|%<6j*awfG`l2x{l^-EZGN@J#5pF&IJ zkSVoPYo(X+Xv0c8%MmYs9tio^xvt_V%3W~xuggQ+cGau723%nfYxu2}3=qLuo~p18 z>nR~v{0KiSfxCC$nS{4D4`0}yLm;e7Ajmz3svJU-sP4T3HIJGO+J)y)v_6O0&Pmku zZpfp)t2u}87;2@mflBWL=6kpJB&<2lYSVbZRjlE*u*Kg*|BDXFwP_4>P5$sRIV>JS z;Ji;<|NGDDsBiI0KTFGg!pnS9Sl;Vx^i5zz_XJkDY6%bB<|TSCjLTTUzczX4qgcqb z8cTWQ2x{;G=3z5xv7P^EZ3v?i4cLc9q88x@nh?igj=LpD6LF60ULecEq~|idjnKm= z3A;+Ne!&L(j%Jt4{Rk4Xn386aH^N98Sp&Z$k?~&S9-;Ilyv*!2a~y4=orf8m Date: Mon, 4 Jul 2016 19:05:42 +0800 Subject: [PATCH 3/7] CountMostImport ZhaoXin --- CountMostImport/.idea/compiler.xml | 22 + .../.idea/copyright/profiles_settings.xml | 3 + .../.idea/libraries/KotlinJavaRuntime.xml | 12 + CountMostImport/.idea/misc.xml | 26 + CountMostImport/.idea/modules.xml | 8 + CountMostImport/.idea/workspace.xml | 525 ++++++++++++++++++ CountMostImport/CountMostImport.iml | 12 + .../CountMostImport/CountImport.class | Bin 0 -> 3581 bytes .../CountMostImport/CountMostImport.class | Bin 0 -> 1573 bytes .../CountMostImport/JavaFileFilter.class | Bin 0 -> 595 bytes CountMostImport/src/CountImport.java | 87 +++ CountMostImport/src/CountMostImport.java | 33 ++ CountMostImport/src/JavaFileFilter.java | 18 + CountMostImport/test/CountImport.java | 87 +++ CountMostImport/test/CountMostImport.java | 33 ++ .../test/JavaFileFilter (copy).txt | 18 + CountMostImport/test/JavaFileFilter.java | 18 + 17 files changed, 902 insertions(+) create mode 100644 CountMostImport/.idea/compiler.xml create mode 100644 CountMostImport/.idea/copyright/profiles_settings.xml create mode 100644 CountMostImport/.idea/libraries/KotlinJavaRuntime.xml create mode 100644 CountMostImport/.idea/misc.xml create mode 100644 CountMostImport/.idea/modules.xml create mode 100644 CountMostImport/.idea/workspace.xml create mode 100644 CountMostImport/CountMostImport.iml create mode 100644 CountMostImport/out/production/CountMostImport/CountImport.class create mode 100644 CountMostImport/out/production/CountMostImport/CountMostImport.class create mode 100644 CountMostImport/out/production/CountMostImport/JavaFileFilter.class create mode 100644 CountMostImport/src/CountImport.java create mode 100644 CountMostImport/src/CountMostImport.java create mode 100644 CountMostImport/src/JavaFileFilter.java create mode 100644 CountMostImport/test/CountImport.java create mode 100644 CountMostImport/test/CountMostImport.java create mode 100644 CountMostImport/test/JavaFileFilter (copy).txt create mode 100644 CountMostImport/test/JavaFileFilter.java diff --git a/CountMostImport/.idea/compiler.xml b/CountMostImport/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/CountMostImport/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CountMostImport/.idea/copyright/profiles_settings.xml b/CountMostImport/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/CountMostImport/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/CountMostImport/.idea/libraries/KotlinJavaRuntime.xml b/CountMostImport/.idea/libraries/KotlinJavaRuntime.xml new file mode 100644 index 0000000..c630c0b --- /dev/null +++ b/CountMostImport/.idea/libraries/KotlinJavaRuntime.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/CountMostImport/.idea/misc.xml b/CountMostImport/.idea/misc.xml new file mode 100644 index 0000000..c6d8fb7 --- /dev/null +++ b/CountMostImport/.idea/misc.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CountMostImport/.idea/modules.xml b/CountMostImport/.idea/modules.xml new file mode 100644 index 0000000..f5092c1 --- /dev/null +++ b/CountMostImport/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/CountMostImport/.idea/workspace.xml b/CountMostImport/.idea/workspace.xml new file mode 100644 index 0000000..46bec5a --- /dev/null +++ b/CountMostImport/.idea/workspace.xml @@ -0,0 +1,525 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1467297922760 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CountMostImport/CountMostImport.iml b/CountMostImport/CountMostImport.iml new file mode 100644 index 0000000..245d342 --- /dev/null +++ b/CountMostImport/CountMostImport.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/CountMostImport/out/production/CountMostImport/CountImport.class b/CountMostImport/out/production/CountMostImport/CountImport.class new file mode 100644 index 0000000000000000000000000000000000000000..c1d8b3f18528cd0307e1ab85e82f027390899d75 GIT binary patch literal 3581 zcmbtWYjhlC8Ga@^$?Rp)rrR#imXuHm}nBgW^Oo!QPx^mqZArrwzU?|uVMK$({B`cQEDAvLZ!xDQgjD2Fa z!^n%>5f=+$*{|RWQN%GOmT^J3ODtbhaCZb>!htaEiQ-;-Im*L*3ceD><;Vz$i5R|$ z`(t1rH0}BQdPTqe9tZ;`nt1-w5NI3LcN52^qosmVzh5;mI(b68pEqI4JhX zFs2lIN5LTpkr6FF;%K|Fx`agc9&NwYR&b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cu`>;yMM*XsBiai|(a-mKSR5^NakjMOo>2{$nI? zPFWaHoCfnK@?1(9m>pKM zk1}ISzNeVM>>O2c?=W6qnXkqx0Ryqfg1#)W)uGU$7ON(NRE$*OOL~BV3YICjqWPjo KaFxd#)_wt hashtable; + public CountImport() + { + this.hashtable=new Hashtable(); + + } + public void count(File java_file) + { + try + { + Scanner scan = new Scanner(java_file); + String line; + String[] tokens; + while(scan.hasNextLine()) + { + line=scan.nextLine(); + line.trim(); + if(line.startsWith("import") && !line.contains("*")) + { + tokens=line.split(" "); + if(hashtable.containsKey(tokens[1])) + { + hashtable.replace(tokens[1],hashtable.get(tokens[1])+1); + } + else + { + hashtable.put(tokens[1],1); + } + } + } + } + catch (java.io.FileNotFoundException e) + { + System.out.println("文件不存在"); + System.exit(0); + } + + } + public void getMostImport() + { + ArrayList> sequence_line=new ArrayList>(); //单调队列 + Iterator> ite=hashtable.entrySet().iterator(); + while(ite.hasNext()) + { + Entry current_entry=ite.next(); + for(int i=0;i<10;i++) + { + try + { + if (sequence_line.get(i).getValue().compareTo(current_entry.getValue())<0) + { + sequence_line.add(i,current_entry); + break; + } + } + catch (IndexOutOfBoundsException e) + { + sequence_line.add(i,current_entry); + break; + } + } + + } + System.out.println("import 最多的10个类是:"); + for (int i=0;i<10;i++) + { + try + { + System.out.println(sequence_line.get(i).getKey()+"被import"+sequence_line.get(i).getValue()+"次"); + } + catch (IndexOutOfBoundsException e) + { + System.out.println("被引用的类不足10个"); + break; + } + } + } +} diff --git a/CountMostImport/src/CountMostImport.java b/CountMostImport/src/CountMostImport.java new file mode 100644 index 0000000..d7798c6 --- /dev/null +++ b/CountMostImport/src/CountMostImport.java @@ -0,0 +1,33 @@ +/** + * Created by zhaoxin on 16-6-30. + */ +import java.io.File; +import java.lang.String; +import java.util.Scanner; +import java.lang.System; + +public class CountMostImport { + + public static void main(String[] args) + { + Scanner scan=new Scanner(System.in); + System.out.print("输入目录名:"); + String file_name=scan.next(); + File directory=new File(file_name); + if(!directory.exists() || !directory.isDirectory()) + { + System.out.println("目录不存在或错误"); + System.exit(0); + } + JavaFileFilter java_file_filter=new JavaFileFilter(); + File[] java_files=directory.listFiles(java_file_filter); + CountImport cout_import=new CountImport(); + for (File file : java_files) + { + cout_import.count(file); + } + cout_import.getMostImport(); + } + +} + diff --git a/CountMostImport/src/JavaFileFilter.java b/CountMostImport/src/JavaFileFilter.java new file mode 100644 index 0000000..14b0f35 --- /dev/null +++ b/CountMostImport/src/JavaFileFilter.java @@ -0,0 +1,18 @@ +/** + * Created by zhaoxin on 16-6-30. + */ +import java.io.File; +import java.io.FilenameFilter; +import java.lang.String; + +public class JavaFileFilter implements FilenameFilter{ + public boolean accept(File dir,String name) + { + if(name.endsWith(".java")) + { + return true; + } + else + return false; + } +} diff --git a/CountMostImport/test/CountImport.java b/CountMostImport/test/CountImport.java new file mode 100644 index 0000000..0e0e598 --- /dev/null +++ b/CountMostImport/test/CountImport.java @@ -0,0 +1,87 @@ +/** + * Created by zhaoxin on 16-6-30. + */ +import java.util.*; +import java.util.Map.Entry; +import java.io.File; +import java.lang.Integer; + +public class CountImport { + private Hashtable hashtable; + public CountImport() + { + this.hashtable=new Hashtable(); + + } + public void count(File java_file) + { + try + { + Scanner scan = new Scanner(java_file); + String line; + String[] tokens; + while(scan.hasNextLine()) + { + line=scan.nextLine(); + line.trim(); + if(line.startsWith("import")) + { + tokens=line.split(" "); + if(hashtable.containsKey(tokens[1])) + { + hashtable.replace(tokens[1],hashtable.get(tokens[1])+1); + } + else + { + hashtable.put(tokens[1],1); + } + } + } + } + catch (java.io.FileNotFoundException e) + { + System.out.println("文件不存在"); + System.exit(0); + } + + } + public void getMostImport() + { + ArrayList> sequence_line=new ArrayList>(); //单调队列 + Iterator> ite=hashtable.entrySet().iterator(); + while(ite.hasNext()) + { + Entry current_entry=ite.next(); + for(int i=0;i<10;i++) + { + try + { + if (sequence_line.get(i).getValue().compareTo(current_entry.getValue())<0) + { + sequence_line.add(i,current_entry); + break; + } + } + catch (IndexOutOfBoundsException e) + { + sequence_line.add(i,current_entry); + break; + } + } + + } + System.out.println("import 最多的10个类是:"); + for (int i=0;i<10;i++) + { + try + { + System.out.println(sequence_line.get(i).getKey()+"被import"+sequence_line.get(i).getValue()+"次"); + } + catch (IndexOutOfBoundsException e) + { + System.out.println("被引用的类不足10个"); + break; + } + } + } +} diff --git a/CountMostImport/test/CountMostImport.java b/CountMostImport/test/CountMostImport.java new file mode 100644 index 0000000..d7798c6 --- /dev/null +++ b/CountMostImport/test/CountMostImport.java @@ -0,0 +1,33 @@ +/** + * Created by zhaoxin on 16-6-30. + */ +import java.io.File; +import java.lang.String; +import java.util.Scanner; +import java.lang.System; + +public class CountMostImport { + + public static void main(String[] args) + { + Scanner scan=new Scanner(System.in); + System.out.print("输入目录名:"); + String file_name=scan.next(); + File directory=new File(file_name); + if(!directory.exists() || !directory.isDirectory()) + { + System.out.println("目录不存在或错误"); + System.exit(0); + } + JavaFileFilter java_file_filter=new JavaFileFilter(); + File[] java_files=directory.listFiles(java_file_filter); + CountImport cout_import=new CountImport(); + for (File file : java_files) + { + cout_import.count(file); + } + cout_import.getMostImport(); + } + +} + diff --git a/CountMostImport/test/JavaFileFilter (copy).txt b/CountMostImport/test/JavaFileFilter (copy).txt new file mode 100644 index 0000000..14b0f35 --- /dev/null +++ b/CountMostImport/test/JavaFileFilter (copy).txt @@ -0,0 +1,18 @@ +/** + * Created by zhaoxin on 16-6-30. + */ +import java.io.File; +import java.io.FilenameFilter; +import java.lang.String; + +public class JavaFileFilter implements FilenameFilter{ + public boolean accept(File dir,String name) + { + if(name.endsWith(".java")) + { + return true; + } + else + return false; + } +} diff --git a/CountMostImport/test/JavaFileFilter.java b/CountMostImport/test/JavaFileFilter.java new file mode 100644 index 0000000..14b0f35 --- /dev/null +++ b/CountMostImport/test/JavaFileFilter.java @@ -0,0 +1,18 @@ +/** + * Created by zhaoxin on 16-6-30. + */ +import java.io.File; +import java.io.FilenameFilter; +import java.lang.String; + +public class JavaFileFilter implements FilenameFilter{ + public boolean accept(File dir,String name) + { + if(name.endsWith(".java")) + { + return true; + } + else + return false; + } +} From 78a29d703a8a4a9218c2d0374861cee199536de6 Mon Sep 17 00:00:00 2001 From: "zhaoxin.zhao" Date: Sat, 9 Jul 2016 19:46:56 +0800 Subject: [PATCH 4/7] test --- testt | 1 + 1 file changed, 1 insertion(+) create mode 100644 testt diff --git a/testt b/testt new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/testt @@ -0,0 +1 @@ +test From fa60c40abaf0e125c83cde3cb7c21ffd01f3682d Mon Sep 17 00:00:00 2001 From: "zhaoxin.zhao" Date: Sat, 9 Jul 2016 19:50:26 +0800 Subject: [PATCH 5/7] homework commit --- Top10Ip | 1 + linux2 | 1 + 2 files changed, 2 insertions(+) create mode 100644 Top10Ip create mode 100644 linux2 diff --git a/Top10Ip b/Top10Ip new file mode 100644 index 0000000..39cd3cb --- /dev/null +++ b/Top10Ip @@ -0,0 +1 @@ +cat * | sort | uniq -c | sort | tail -10 diff --git a/linux2 b/linux2 new file mode 100644 index 0000000..4668498 --- /dev/null +++ b/linux2 @@ -0,0 +1 @@ +scp dirl/test 1-test.dev.cn1:/temp From 5d5733c4923b4a0b4b74bd9ba6d3a52de001a66e Mon Sep 17 00:00:00 2001 From: "zhaoxin.zhao" Date: Sat, 9 Jul 2016 19:53:37 +0800 Subject: [PATCH 6/7] delete ReadeMe testt --- ReadMe | 1 - testt | 1 - 2 files changed, 2 deletions(-) delete mode 100644 ReadMe delete mode 100644 testt diff --git a/ReadMe b/ReadMe deleted file mode 100644 index 33ad5f8..0000000 --- a/ReadMe +++ /dev/null @@ -1 +0,0 @@ -Hello,My name is ZhaoXin. diff --git a/testt b/testt deleted file mode 100644 index 9daeafb..0000000 --- a/testt +++ /dev/null @@ -1 +0,0 @@ -test From c2db183ba3b907ba517af926f4c0f6f044a6153f Mon Sep 17 00:00:00 2001 From: "zhaoxin.zhao" Date: Sun, 10 Jul 2016 16:58:46 +0800 Subject: [PATCH 7/7] ExchangeRate commit --- ExchangeRate/.idea/.name | 1 + ExchangeRate/.idea/compiler.xml | 23 + .../.idea/copyright/profiles_settings.xml | 3 + ExchangeRate/.idea/encodings.xml | 4 + ExchangeRate/.idea/libraries/jexcelapi.xml | 15 + ExchangeRate/.idea/libraries/lib.xml | 10 + ExchangeRate/.idea/libraries/lib1.xml | 12 + ExchangeRate/.idea/libraries/lib2.xml | 10 + ExchangeRate/.idea/libraries/src0_82.xml | 9 + ExchangeRate/.idea/misc.xml | 168 +++++ ExchangeRate/.idea/modules.xml | 8 + ExchangeRate/.idea/scopes/scope_settings.xml | 5 + ExchangeRate/.idea/uiDesigner.xml | 124 +++ ExchangeRate/.idea/vcs.xml | 6 + ExchangeRate/.idea/workspace.xml | 714 ++++++++++++++++++ ExchangeRate/ExchangeRate.iml | 15 + ExchangeRate/ExchangeRate.xls | Bin 0 -> 13824 bytes .../ExchangeRate/ExchangeRate.class | Bin 0 -> 7140 bytes ExchangeRate/src/ExchangeRate.java | 216 ++++++ 19 files changed, 1343 insertions(+) create mode 100644 ExchangeRate/.idea/.name create mode 100644 ExchangeRate/.idea/compiler.xml create mode 100644 ExchangeRate/.idea/copyright/profiles_settings.xml create mode 100644 ExchangeRate/.idea/encodings.xml create mode 100644 ExchangeRate/.idea/libraries/jexcelapi.xml create mode 100644 ExchangeRate/.idea/libraries/lib.xml create mode 100644 ExchangeRate/.idea/libraries/lib1.xml create mode 100644 ExchangeRate/.idea/libraries/lib2.xml create mode 100644 ExchangeRate/.idea/libraries/src0_82.xml create mode 100644 ExchangeRate/.idea/misc.xml create mode 100644 ExchangeRate/.idea/modules.xml create mode 100644 ExchangeRate/.idea/scopes/scope_settings.xml create mode 100644 ExchangeRate/.idea/uiDesigner.xml create mode 100644 ExchangeRate/.idea/vcs.xml create mode 100644 ExchangeRate/.idea/workspace.xml create mode 100644 ExchangeRate/ExchangeRate.iml create mode 100644 ExchangeRate/ExchangeRate.xls create mode 100644 ExchangeRate/out/production/ExchangeRate/ExchangeRate.class create mode 100644 ExchangeRate/src/ExchangeRate.java diff --git a/ExchangeRate/.idea/.name b/ExchangeRate/.idea/.name new file mode 100644 index 0000000..3ed68d2 --- /dev/null +++ b/ExchangeRate/.idea/.name @@ -0,0 +1 @@ +ExchangeRate \ No newline at end of file diff --git a/ExchangeRate/.idea/compiler.xml b/ExchangeRate/.idea/compiler.xml new file mode 100644 index 0000000..a852314 --- /dev/null +++ b/ExchangeRate/.idea/compiler.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/ExchangeRate/.idea/copyright/profiles_settings.xml b/ExchangeRate/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/ExchangeRate/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ExchangeRate/.idea/encodings.xml b/ExchangeRate/.idea/encodings.xml new file mode 100644 index 0000000..d821048 --- /dev/null +++ b/ExchangeRate/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ExchangeRate/.idea/libraries/jexcelapi.xml b/ExchangeRate/.idea/libraries/jexcelapi.xml new file mode 100644 index 0000000..674161c --- /dev/null +++ b/ExchangeRate/.idea/libraries/jexcelapi.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ExchangeRate/.idea/libraries/lib.xml b/ExchangeRate/.idea/libraries/lib.xml new file mode 100644 index 0000000..cd8670c --- /dev/null +++ b/ExchangeRate/.idea/libraries/lib.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ExchangeRate/.idea/libraries/lib1.xml b/ExchangeRate/.idea/libraries/lib1.xml new file mode 100644 index 0000000..5d66a56 --- /dev/null +++ b/ExchangeRate/.idea/libraries/lib1.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ExchangeRate/.idea/libraries/lib2.xml b/ExchangeRate/.idea/libraries/lib2.xml new file mode 100644 index 0000000..3714b28 --- /dev/null +++ b/ExchangeRate/.idea/libraries/lib2.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ExchangeRate/.idea/libraries/src0_82.xml b/ExchangeRate/.idea/libraries/src0_82.xml new file mode 100644 index 0000000..bc2ccb3 --- /dev/null +++ b/ExchangeRate/.idea/libraries/src0_82.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ExchangeRate/.idea/misc.xml b/ExchangeRate/.idea/misc.xml new file mode 100644 index 0000000..1110500 --- /dev/null +++ b/ExchangeRate/.idea/misc.xml @@ -0,0 +1,168 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ExchangeRate/.idea/modules.xml b/ExchangeRate/.idea/modules.xml new file mode 100644 index 0000000..0147aad --- /dev/null +++ b/ExchangeRate/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ExchangeRate/.idea/scopes/scope_settings.xml b/ExchangeRate/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/ExchangeRate/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/ExchangeRate/.idea/uiDesigner.xml b/ExchangeRate/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/ExchangeRate/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ExchangeRate/.idea/vcs.xml b/ExchangeRate/.idea/vcs.xml new file mode 100644 index 0000000..6564d52 --- /dev/null +++ b/ExchangeRate/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ExchangeRate/.idea/workspace.xml b/ExchangeRate/.idea/workspace.xml new file mode 100644 index 0000000..a59fc1c --- /dev/null +++ b/ExchangeRate/.idea/workspace.xml @@ -0,0 +1,714 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1468031900529 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No facets are configured + + + + + + + + + + + + + + + 1.7 + + + + + + + + ExchangeRate + + + + + + + + + + + + + + + jexcelapi + + + + + + + + \ No newline at end of file diff --git a/ExchangeRate/ExchangeRate.iml b/ExchangeRate/ExchangeRate.iml new file mode 100644 index 0000000..52f6c88 --- /dev/null +++ b/ExchangeRate/ExchangeRate.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ExchangeRate/ExchangeRate.xls b/ExchangeRate/ExchangeRate.xls new file mode 100644 index 0000000000000000000000000000000000000000..f8c90c1b74699e975067082399b661198e8a8c80 GIT binary patch literal 13824 zcmeHOTW?HJ6#n*fX4<0DnQ2`^Oo*T+MN3AT{s2iIBpBaXr$=2nQ3(mM*2&&$?{BYj*4p3R`<$0`UcQJG zZrz(UfbV1#%J8XJiSSprV|%LKkAmaHqI7*dg>6D6{}2O}6zI0;U$?l#^qP2ZvqOYO8slF-k=VT4NzX_(D#ITaJ!%ZR)?mt1| zTGwcOM{OQ?mK-_gBCd1!UA66aD2UXYP%T*%})wTIhaj%|%iai5f zScXQlb$n&B@QCXY8$yd{(}E?mYGV1uYHshBCpFWmkE*Z=&coZ=&%5?{sijPwDy)(9cq(=XV0@{ixPkC@n!You0^CWwt^u>6q54>em}{5fNxiA>xWWaM~cZK%IH^xosY@@7?p_Eb2>A> z7hq3fl`*+n;`e)EDc-y>u_Q%!&4^^9*P;%q0&(2ePx)#hE6AG2jN$v(l!uAPLYNo> z#(*(k3>X8(fH7bU7z4(DF<=ZB1IBX8(fH7bU7z4(DF<=ZB1IBX8(fH7bU{KX7N;-}=RO8%(imrCZSB#O$<0P%=&fRr zELX`?mGKyLoTY}v&!3&d_GA_r|HvZR7auH4vV5_gP0Ge3#= zXLrkf@NIU|dltRer*ZW9@R+sy2_k#fk73L=dWqSLej85UFt4=EeIr>opfL%OV|Myc wBBf;>{mZ=l7)o1?j4)Fi_~L&pJ#=dfJ-PzF7EcTP`*RmP;-z#;T@U;J3^%lr!~g&Q literal 0 HcmV?d00001 diff --git a/ExchangeRate/out/production/ExchangeRate/ExchangeRate.class b/ExchangeRate/out/production/ExchangeRate/ExchangeRate.class new file mode 100644 index 0000000000000000000000000000000000000000..c1d501013552fc941dddfc1e9192ac3b44761585 GIT binary patch literal 7140 zcmbVQ3wRXQb^hCT;d&pr2?bN}<-GyAP;XU_vzD7O2t6B!k!3!veQf>-?TAR}MS%I2JGUX{&j zvNLdn#b3$hujSm|D0ov2|E+@WsrWlTs_}h4et^H1%|EEP=*JBFP{ohr^B-0GSU&$r zHvcS}pU6#qs^XH0K?Ro!@D_fi;^%(+3;tEXFZ{Sw`uDbcz9U6{DSQ8>;@{=-KNS3@ zivRLs8GcoW|Hl7FiC-(Qq+3^1{I80u(vx>(bIp%=81myS0Zt2{2$vtXQ@e1h!o#lc z(sY_cK(0&3cfb@V3s41qxVZhfyF zis|v5P}nk~@t&muMX_jnPlptWMN^hQxg(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#`xo3usA zvBOrmn?JW({dO86Uzz;J`-isKh6T3qT_#NbQ0qy0zl6VoUmVVrI8PZQeIL2HnCDVK zrk+8To<;O6A+lPDsScvbAfl4Q)IQ?rAaV2{G4wRi^E^@WB5^W6%zTO1c!TKp9&zyl zJjz`T<41THgLni#=ld`4X&c`MiPoo?e@_vGe(KrAw+DC|wBj*5!!a*+irNVFalcM{ zhS*iOYX_d?IDfk5dWlvqF@N61sJw;V&SFpYo}(PUcJN~y!{>PJ75F~>m|nPPH;7kv zcGo}QuFek6a|cJ;VP=8EXc)>hgcS7KU?fJv@DodfQg(zuv_bj;haLs4qJbkgn`Sg-$$tO`HVOAJh-Ve>`d3G)Ltf;E=>^g>d5`o!M zXP0+mQ(!xrDtRgV&IkYwxp|*_M+)cPo)g>+@)CFGvX+McriP1_74T3>c?gvZ`YjB1 zJD-~w#0bNe=3z^Ex|M;S!S?eEvKu>wX@Z^%AHm-25x5AcFHp{92VPbij(m;?roeX< zr9!<5A+BKIRVYs8avT1vkqy*AZYax{r-<&rT|{$bqqnNjS68{9St<9H`;OsG=P|Rc z+_ykp^*f%y8h63iC}!j~A)0i< z=^OS5Y<9vi9POv@MaG%*$kQ9Jqb++U?DLVmlk9nD&BIL5D1%wd)A%xbK3evGeYq$$ c link_url_list =new ArrayList(); //一级目录list + + private ArrayList data_url_list =new ArrayList(); //二级目录list + + private ArrayList USDollarExchange=new ArrayList(); + + private ArrayList HongKongDollarExchange=new ArrayList(); + + private ArrayList EuropeDollarExchange=new ArrayList(); + + WritableWorkbook xls; + + private int url_num_perpage=20; //一页有20条有效的url + + public static void main(String[] args) + { + ExchangeRate exchange_rate=new ExchangeRate(); + exchange_rate.getUrlDataList(30); + exchange_rate.parseData(); + } + + private void parseData() + { + try + { + WritableWorkbook xls= Workbook.createWorkbook(new File("ExchangeRate.xls")); + WritableSheet sheet=xls.createSheet("FirstSheet",0); + for (Iterator ite= data_url_list.iterator();ite.hasNext();) + { + try + { + WebClient client=new WebClient(); + client.getOptions().setCssEnabled(true); + client.getOptions().setJavaScriptEnabled(true); + HtmlPage page=client.getPage(ite.next()); + DomElement table=page.getElementById("zoom"); + DomElement first_chiled=table.getFirstElementChild(); + String data=first_chiled.getTextContent(); + String[] paterns=data.split(","); + for (String tem:paterns) + { + int index=tem.lastIndexOf("人民币"); + if(tem.contains("美元")) { + USDollarExchange.add(tem.substring(index+3,tem.length())); + // System.out.println(tem); + } + else if(tem.contains("欧元")) { + EuropeDollarExchange.add(tem.substring(index+3,tem.length())); + // System.out.println(tem); + } + else if(tem.contains("港元")) { + HongKongDollarExchange.add(tem.substring(index+3,tem.length())); + //System.out.println(tem); + } + } + } + catch(Exception e) + { + System.out.println("error"); + continue; + } + } +// System.out.println("共:"+USDollarExchange.size()+"条数据"); +// for (Iterator ite=USDollarExchange.iterator();ite.hasNext();) +// { +// System.out.println(ite.next()); +// } + // String[] array=USDollarExchange.toArray(new String[0]); + // System.out.println("美元中间值是:"+); + Label label=new Label(0,0,"人民币对美元汇率"); + sheet.addCell(label); + label=new Label(0,1,binarySearch(USDollarExchange.toArray(new String[0]),0,29,14)); + sheet.addCell(label); + label=new Label(1,0,"人民币对港币汇率"); + sheet.addCell(label); + label=new Label(1,1,binarySearch(HongKongDollarExchange.toArray(new String[0]),0,29,14)); + sheet.addCell(label); + label=new Label(2,0,"人民币对欧元汇率"); + sheet.addCell(label); + label=new Label(2,1,binarySearch(EuropeDollarExchange.toArray(new String[0]),0,29,14)); + sheet.addCell(label); + xls.write(); + xls.close(); + } + catch(Exception e) + { + System.out.println("error"+e.getMessage()); + System.exit(0); + } + } + private void getUrlDataList(int data_url_num) //获取二级url. data_url_num所需二级url数目. + { + getLinkUrlList(30); + Parser parser=new Parser(); + WebClient webclient=new WebClient(); + webclient.getOptions().setJavaScriptEnabled(true); + webclient.getOptions().setCssEnabled(true); + for(Iterator ite= link_url_list.iterator();ite.hasNext();) + { + try + { + String tt=ite.next(); + System.out.println("正在parser "+tt); + parser.setEncoding("utf-8"); + HtmlPage page=webclient.getPage(tt); + List anchors=page.getAnchors(); + int flag=0; + for (Iterator iterator=anchors.iterator();iterator.hasNext();) + { + String temp=iterator.next().getHrefAttribute(); + if (temp.matches("/zhengcehuobisi/125207/125217/125925/[0-9]{7}/index.html")) + { + flag++; + if(1==flag) + continue; //匹配到的第一个URL是无效的. + data_url_list.add("http://www.pbc.gov.cn" + temp); + System.out.println(temp); + } + } + } + catch(Exception e) + { + System.out.println("在parsser fetchURL时发生错误:"); + System.exit(0); + } + + } + + } + private void getLinkUrlList(int data_url_num) //获取一级url  data_url_num所需二级url数目. + { + int url_fetch_num=0; + if(data_url_num %26==0) + url_fetch_num= data_url_num /this.url_num_perpage; + else + url_fetch_num= data_url_num /this.url_num_perpage+1; + for (int i=1;i ite= link_url_list.iterator();ite.hasNext(); ) + { + System.out.println(ite.next()); + } + } + String binarySearch(String[] list , int start , int tail , int destination) //在list中寻求排序位于destination位置的值 + { + System.out.println("running"); + int index_head=start; + int index_tail=tail; + String tem=list[start]; + while(index_head=0) + { + list[index_tail]=list[index_head]; + index_tail--; + break; + } + } + } + list[index_head]=tem; + if(index_head==destination) + return list[index_head]; + else if(index_head