diff --git a/CountMostImport/.gitattributes b/CountMostImport/.gitattributes new file mode 100644 index 0000000..bdb0cab --- /dev/null +++ b/CountMostImport/.gitattributes @@ -0,0 +1,17 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/CountMostImport/.gitignore b/CountMostImport/.gitignore new file mode 100644 index 0000000..cd2946a --- /dev/null +++ b/CountMostImport/.gitignore @@ -0,0 +1,47 @@ +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# ========================= +# Operating System Files +# ========================= + +# OSX +# ========================= + +.DS_Store +.AppleDouble +.LSOverride + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk diff --git a/CountMostImport/CountMostImport.iml b/CountMostImport/CountMostImport.iml new file mode 100644 index 0000000..c053808 --- /dev/null +++ b/CountMostImport/CountMostImport.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/CountMostImport/CountMostImport.ipr b/CountMostImport/CountMostImport.ipr new file mode 100644 index 0000000..74a8b45 --- /dev/null +++ b/CountMostImport/CountMostImport.ipr @@ -0,0 +1,304 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CountMostImport/CountMostImport.iws b/CountMostImport/CountMostImport.iws new file mode 100644 index 0000000..1fc9798 --- /dev/null +++ b/CountMostImport/CountMostImport.iws @@ -0,0 +1,1148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + project + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost + 5050 + + + + + + + + + + C:\Users\Administrator\AppData\Roaming\Subversion + + + + + 1467471214266 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No facets are configured + + + + + + + + + + + + + + + 1.8 + + + + + + + + CountMostImport + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CountMostImport/out/production/CountMostImport/CoutMostImport/com/ComputeImportClass.class b/CountMostImport/out/production/CountMostImport/CoutMostImport/com/ComputeImportClass.class new file mode 100644 index 0000000..3d220db Binary files /dev/null and b/CountMostImport/out/production/CountMostImport/CoutMostImport/com/ComputeImportClass.class differ diff --git a/CountMostImport/out/production/CountMostImport/CoutMostImport/com/CoutMostImprot_Main.class b/CountMostImport/out/production/CountMostImport/CoutMostImport/com/CoutMostImprot_Main.class new file mode 100644 index 0000000..9a049cc Binary files /dev/null and b/CountMostImport/out/production/CountMostImport/CoutMostImport/com/CoutMostImprot_Main.class differ diff --git a/CountMostImport/out/production/CountMostImport/CoutMostImport/com/EntryComparator.class b/CountMostImport/out/production/CountMostImport/CoutMostImport/com/EntryComparator.class new file mode 100644 index 0000000..6d3e3bf Binary files /dev/null and b/CountMostImport/out/production/CountMostImport/CoutMostImport/com/EntryComparator.class differ diff --git a/CountMostImport/src/CoutMostImport/com/ComputeImportClass.java b/CountMostImport/src/CoutMostImport/com/ComputeImportClass.java new file mode 100644 index 0000000..bb81f26 --- /dev/null +++ b/CountMostImport/src/CoutMostImport/com/ComputeImportClass.java @@ -0,0 +1,109 @@ +package CoutMostImport.com; + +import java.io.*; +import java.util.*; + + +public class ComputeImportClass { + //需要进行识别的字符串名字 + public static String Identify_String="import" ; + public HashMap ImportClass_number; + // File[] sub_file ; + ComputeImportClass() + { + ImportClass_number=new HashMap(); + } + //扫描文件目录下的所有后缀为Java文件,如果是目录则进行目录下所有的文件的扫描,迭代运算直至最终的所有的文件结束 + public void Scanner_File(File file) + { + if(!file.exists()) + return; + //如果文件是目录 + else if(file.isDirectory()) { + //列出目录下的所有文件 + File[] sub_file = file.listFiles(); + for (File f : sub_file) + Scanner_File(f); + } + else + { + //如果文件不是目录 + String File_Name=file.getName(); + if(File_Name.endsWith("java")) + compute_ImprotClass(file); + } + } + //计算Java文件中导入类的数据 + public void compute_ImprotClass(File file) + { + if(!file.exists()) + return; + // FileReader s= null; + try { + // s = new FileReader(file); + BufferedReader Java_File=new BufferedReader(new FileReader(file)); + String s1=""; + while((s1=Java_File.readLine())!=null) + { + String File_Line=s1.trim(); + if(File_Line.startsWith("import")) + { + // int index=File_Line.indexOf('j'); + //存储导入类的名字和次数 + String Class_Name= File_Line.substring(7,File_Line.length()-1); + Integer count=ImportClass_number.get(Class_Name); + //如果导入新的类,则加入Map + if(count==null) + ImportClass_number.put(Class_Name,1); + //如果是原来存在的类,则把此类的导入次数加1 + else + ImportClass_number.put(Class_Name,++count); + } + } + Java_File.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + + } + //从Map中找出导入次数前10的类,并输入导入的次数 + public void Count_TOP10_Class() + { + List> Class_ArrayList = new ArrayList>( + ImportClass_number.entrySet()); + //新建一个比较器,用于对List中的元素进行排序 + EntryComparator comparator = new EntryComparator(); + //对List中的元素按照重载的比较规则进行排序 + Collections.sort(Class_ArrayList, comparator); + /* Collections.sort(Class_ArrayList, new Comparator>() { + public int compare(Map.Entry o1, + Map.Entry o2) { + if(o1.getValue()==o2.getValue()) + { + return o1.getKey().compareTo(o2.getKey()); + } + else + return o1.getValue()-o2.getValue(); + } + }); */ + //如果导入类的个数不足十个,全部进行输出,否则输出前十个次数最多的类 + if(Class_ArrayList.size()<10) + { + for(int i=0;i ent=Class_ArrayList.get(i); + System.out.println("导入类"+ent.getKey()+",其次数为"+ent.getValue()); + } + } + else { + for(int i=0;i<10;i++) + { + Map.Entry ent=Class_ArrayList.get(i); + System.out.println("导入类"+ent.getKey()+",其次数为"+ent.getValue()); + } + } + } +} diff --git a/CountMostImport/src/CoutMostImport/com/CoutMostImprot_Main.java b/CountMostImport/src/CoutMostImport/com/CoutMostImprot_Main.java new file mode 100644 index 0000000..610e498 --- /dev/null +++ b/CountMostImport/src/CoutMostImport/com/CoutMostImprot_Main.java @@ -0,0 +1,33 @@ +package CoutMostImport.com; + +import java.io.File; +import java.util.Scanner; + +/** + * Created by IntelliJ IDEA. + * User: Administrator + * Date: 2016-7-2 + * Time: 22:23:20 + * To change this template use File | Settings | File Templates. + */ +public class CoutMostImprot_Main { + + public static void main(String[] args) { + ComputeImportClass computeimportclass=new ComputeImportClass(); + // Scanner in=new Scanner(System.in); + // String input_s=""; + //while(true) + // { + // String str = in.nextLine(); + // if(str.equals("exit")) + // break; + // input_s=str; + // } + // File Java_file=new File(input_s); + File Java_file=new File("F:\\CountMostImport\\File"); + computeimportclass.Scanner_File(Java_file); + computeimportclass.Count_TOP10_Class(); + +} + +} diff --git a/CountMostImport/src/CoutMostImport/com/EntryComparator.java b/CountMostImport/src/CoutMostImport/com/EntryComparator.java new file mode 100644 index 0000000..cf59a62 --- /dev/null +++ b/CountMostImport/src/CoutMostImport/com/EntryComparator.java @@ -0,0 +1,22 @@ +package CoutMostImport.com; +import java.util.Comparator; +import java.util.Map; + + + //比较Java类被导入的次数 + + +public class EntryComparator implements Comparator> { + + @Override + public int compare(Map.Entry o1, Map.Entry o2) { + //如果两个类的导入次数相同,则按照字典序进行比较 + if(o1.getValue()==o2.getValue()) + { + return o1.getKey().compareTo(o2.getKey()); + } + else + //否则输出两个导入次数的差值 + return o2.getValue()-o1.getValue(); + } +} diff --git a/EffectiveLines/EffectiveLines b/EffectiveLines/EffectiveLines new file mode 160000 index 0000000..300c4aa --- /dev/null +++ b/EffectiveLines/EffectiveLines @@ -0,0 +1 @@ +Subproject commit 300c4aa4200a6d5566e27942b560ecd193f37ef0 diff --git a/EffectiveLines/EffectiveLines.iml b/EffectiveLines/EffectiveLines.iml new file mode 100644 index 0000000..c053808 --- /dev/null +++ b/EffectiveLines/EffectiveLines.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/EffectiveLines/EffectiveLines.ipr b/EffectiveLines/EffectiveLines.ipr new file mode 100644 index 0000000..09cc745 --- /dev/null +++ b/EffectiveLines/EffectiveLines.ipr @@ -0,0 +1,215 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/EffectiveLines/EffectiveLines.iws b/EffectiveLines/EffectiveLines.iws new file mode 100644 index 0000000..ca44b8f --- /dev/null +++ b/EffectiveLines/EffectiveLines.iws @@ -0,0 +1,969 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost + 5050 + + + + + + + + + + + + + + 1467598747901 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/EffectiveLines/out/production/EffectiveLines/Qunar_Teste/com/EffictiveLines_Main.class b/EffectiveLines/out/production/EffectiveLines/Qunar_Teste/com/EffictiveLines_Main.class new file mode 100644 index 0000000..c8d6712 Binary files /dev/null and b/EffectiveLines/out/production/EffectiveLines/Qunar_Teste/com/EffictiveLines_Main.class differ diff --git a/EffectiveLines/out/production/EffectiveLines/Qunar_Teste/com/Statistics_EffictiveLines.class b/EffectiveLines/out/production/EffectiveLines/Qunar_Teste/com/Statistics_EffictiveLines.class new file mode 100644 index 0000000..59972ce Binary files /dev/null and b/EffectiveLines/out/production/EffectiveLines/Qunar_Teste/com/Statistics_EffictiveLines.class differ diff --git a/EffectiveLines/src/Qunar_Teste/com/EffictiveLines_Main.java b/EffectiveLines/src/Qunar_Teste/com/EffictiveLines_Main.java new file mode 100644 index 0000000..7ad2337 --- /dev/null +++ b/EffectiveLines/src/Qunar_Teste/com/EffictiveLines_Main.java @@ -0,0 +1,48 @@ +package Qunar_Teste.com; + +import java.io.*; +import java.util.Scanner; + +/** + 题目:统计一个Java文件的有效行数。 + 1、有效不包括空行 + 2、不考虑代码中有多行注释的情况 + */ +public class EffictiveLines_Main { + + public static void main(String[] args) { + //通过命令行输入待统计的Java文件路径 ,当输入exit结束输入 + Scanner in=new Scanner(System.in); + String input_s=""; + while(true) + { + String str = in.nextLine(); + if(str.equals("exit")) + break; + input_s=str; + } + try{ + //加载Java文件 + File f=new File(input_s); + // File f=new File("F:\\EffectiveLines\\File\\TestCase1.java"); + FileReader s=new FileReader(f); + BufferedReader Java_File=new BufferedReader(s); + int Effictive_Line=0; + //计算Java文件的有效行,并返回有效行数 + Effictive_Line= Statistics_EffictiveLines.Compute_Effictive_Lines(Java_File); + System.out.println(Effictive_Line); + Java_File.close(); + + } + catch(ArrayIndexOutOfBoundsException e) + { + System.out.println("没有指定文件"); + } + catch(IOException e) { + e.printStackTrace(); + } + + } + + +} diff --git a/EffectiveLines/src/Qunar_Teste/com/Statistics_EffictiveLines.java b/EffectiveLines/src/Qunar_Teste/com/Statistics_EffictiveLines.java new file mode 100644 index 0000000..05dc40d --- /dev/null +++ b/EffectiveLines/src/Qunar_Teste/com/Statistics_EffictiveLines.java @@ -0,0 +1,33 @@ +package Qunar_Teste.com; + +import java.io.BufferedReader; +import java.io.IOException; + + + //缁熻Java鏂囦欢鐨勬湁鏁堣鏁帮紝骞惰緭鍏ュ搴旂殑鏈夋晥琛屾暟 + + +public class Statistics_EffictiveLines +{ + public static int Compute_Effictive_Lines(BufferedReader File_Reader) + { + //鏈夋晥琛屾暟 + int Row_Number=0; + String s=""; + try { + while((s=File_Reader.readLine())!=null) + { + String File_Line=s.trim(); + //鐢变簬涓嶈冭檻澶氳娉ㄩ噴锛屽幓闄ょ┖琛屽拰鍗曡娉ㄩ噴鍗虫槸鏈夋晥琛屾暟 + if((File_Line.isEmpty())||File_Line.startsWith("//")|| (File_Line.startsWith("/*") && File_Line.endsWith("*/"))) + continue; + else + Row_Number++; + + } + } catch (IOException e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + return Row_Number; + } +} diff --git a/ExchangeRata/.idea/compiler.xml b/ExchangeRata/.idea/compiler.xml new file mode 100644 index 0000000..217af47 --- /dev/null +++ b/ExchangeRata/.idea/compiler.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/ExchangeRata/.idea/copyright/profiles_settings.xml b/ExchangeRata/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/ExchangeRata/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ExchangeRata/.idea/description.html b/ExchangeRata/.idea/description.html new file mode 100644 index 0000000..db5f129 --- /dev/null +++ b/ExchangeRata/.idea/description.html @@ -0,0 +1 @@ +Simple Java application that includes a class with main() method \ No newline at end of file diff --git a/ExchangeRata/.idea/encodings.xml b/ExchangeRata/.idea/encodings.xml new file mode 100644 index 0000000..e206d70 --- /dev/null +++ b/ExchangeRata/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/ExchangeRata/.idea/misc.xml b/ExchangeRata/.idea/misc.xml new file mode 100644 index 0000000..693b540 --- /dev/null +++ b/ExchangeRata/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ExchangeRata/.idea/modules.xml b/ExchangeRata/.idea/modules.xml new file mode 100644 index 0000000..664bc19 --- /dev/null +++ b/ExchangeRata/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ExchangeRata/.idea/workspace.xml b/ExchangeRata/.idea/workspace.xml new file mode 100644 index 0000000..38ad4c5 --- /dev/null +++ b/ExchangeRata/.idea/workspace.xml @@ -0,0 +1,828 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + project + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1467511393716 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No facets are configured + + + + + + + + + + + + + + + 1.8 + + + + + + + + ExchangeData + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ExchangeRata/ExchangeData.iml b/ExchangeRata/ExchangeData.iml new file mode 100644 index 0000000..96f8398 --- /dev/null +++ b/ExchangeRata/ExchangeData.iml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ExchangeRata/Rate.xls b/ExchangeRata/Rate.xls new file mode 100644 index 0000000..253e4ba Binary files /dev/null and b/ExchangeRata/Rate.xls differ diff --git a/ExchangeRata/jsoup-1.9.2.jar b/ExchangeRata/jsoup-1.9.2.jar new file mode 100644 index 0000000..720b761 Binary files /dev/null and b/ExchangeRata/jsoup-1.9.2.jar differ diff --git a/ExchangeRata/jxl.jar b/ExchangeRata/jxl.jar new file mode 100644 index 0000000..c68a0be Binary files /dev/null and b/ExchangeRata/jxl.jar differ diff --git a/ExchangeRata/out/production/ExchangeData/ExchangeData.class b/ExchangeRata/out/production/ExchangeData/ExchangeData.class new file mode 100644 index 0000000..6f480f4 Binary files /dev/null and b/ExchangeRata/out/production/ExchangeData/ExchangeData.class differ diff --git a/ExchangeRata/out/production/ExchangeData/Main.class b/ExchangeRata/out/production/ExchangeData/Main.class new file mode 100644 index 0000000..8d4faa5 Binary files /dev/null and b/ExchangeRata/out/production/ExchangeData/Main.class differ diff --git a/ExchangeRata/out/production/ExchangeData/Rate_Record.class b/ExchangeRata/out/production/ExchangeData/Rate_Record.class new file mode 100644 index 0000000..8212c21 Binary files /dev/null and b/ExchangeRata/out/production/ExchangeData/Rate_Record.class differ diff --git a/ExchangeRata/src/ExchangeData.java b/ExchangeRata/src/ExchangeData.java new file mode 100644 index 0000000..e3ecd40 --- /dev/null +++ b/ExchangeRata/src/ExchangeData.java @@ -0,0 +1,104 @@ +import java.io.File; +import java.io.IOException; +import java.net.SocketTimeoutException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + +import com.sun.rowset.internal.Row; +import jxl.Workbook; +import jxl.write.WritableSheet; +import jxl.write.WritableWorkbook; +import jxl.write.WriteException; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.select.Elements; + +/** + 主要通过Jsoup进行网页的内容的解析 + */ +public class ExchangeData { + //汇率记录列表 + private static List Rate_List; + + public ExchangeData() { + Rate_List = new ArrayList(); + } +//根据网址,应用Jsoup进行解析,找出30天内不同种类的货币对人民的汇率 + public static Document getDataByJsoup(String url) { + Document doc2 = null; + SimpleDateFormat Date_Format = new SimpleDateFormat("yyyy-MM-dd"); + //获取当前日期 + Calendar C_Time = Calendar.getInstance(); + //获取当前日期前30天的日期 + Calendar P_Time = Calendar.getInstance(); + P_Time.add(P_Time.DATE, -30); + try { + //获取一个新的连接,用get()取得和解析一个HTML + doc2 = Jsoup.connect(url).timeout(6000) + .data("projectBean.startDate", Date_Format.format(P_Time.getTime())) + .data("projectBean.endDate", Date_Format.format(C_Time.getTime())) + .get(); + String title = doc2.body().toString(); + } catch (SocketTimeoutException e) { + System.out.println("Socket连接超时"); + } catch (IOException e) { + e.printStackTrace(); + } + return doc2; + } + //对Jsoup解析出的网页进行分析 + public static void Pars_HTML() { + //最终输出的xls表格中第一行数据 + Rate_Record Zero_record = new Rate_Record("港币", "欧元", "美元", "日期"); + Rate_List.add(Zero_record); + //待抓取的网页数据 + Document doc = ExchangeData.getDataByJsoup + ("http://www.safe.gov.cn/AppStructured/view/project_RMBQuery.action"); + String title = doc.body().toString(); + //从网页数据可以分析,得到所有的汇率数据都处于first类下面,所有只需对class=“first”下的节点进行解析 + Elements elements = doc.getElementsByClass("first"); + for (Element element : elements) { + //从网页数据可以发现,汇率所需的数据的时间、港币对人民币、欧元兑人民币、美元对人民币分别位于0、4、1、2子节点中。 + Rate_Record temp_record = new Rate_Record(); + temp_record.setDate(element.child(0).text()); + temp_record.setEurcny(element.child(2).text()); + temp_record.setHkdcny(element.child(4).text()); + temp_record.setUsdcny(element.child(1).text()); + //把一条记录加入汇率记录中 + Rate_List.add(temp_record); + + } + } + public static void Export_Excel(String Excel_Name) { + File Excel_File = new File(Excel_Name); + String worksheet = "人民币对美欧港元汇率";//输出的excel文件工作表名 + WritableWorkbook workbook; + try { + //创建可写入的Excel工作薄,运行生成的文件在tomcat/bin下 + //workbook = Workbook.createWorkbook(new File("output.xls")) + workbook = Workbook.createWorkbook(Excel_File); + WritableSheet sheet = workbook.createSheet(worksheet, 0); //添加第一个工作表 + for (int i = 0; i < Rate_List.size(); i++) { + //添加对应标签下的数据到xls对应表格中 + jxl.write.Label Date_label = new jxl.write.Label(0, i, Rate_List.get(i).getDate()); //当前日期数据 + jxl.write.Label HK_label = new jxl.write.Label(1, i, Rate_List.get(i).getHkdcny()); //港币对人民币的汇率数据 + jxl.write.Label EU_label = new jxl.write.Label(2, i, Rate_List.get(i).getEurcny()); //欧元对人民币的汇率数据 + jxl.write.Label US_label = new jxl.write.Label(3, i, Rate_List.get(i).getUsdcny()); //美元对人民币的汇率数据 + sheet.addCell(Date_label); + sheet.addCell(HK_label); + sheet.addCell(EU_label); + sheet.addCell(US_label); + } + workbook.write(); + workbook.close(); + + } catch (WriteException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/ExchangeRata/src/Main.java b/ExchangeRata/src/Main.java new file mode 100644 index 0000000..a45545d --- /dev/null +++ b/ExchangeRata/src/Main.java @@ -0,0 +1,12 @@ +public class Main { + + public static void main(String[] args) { + //鏂板缓涓涓腑闂存眹鐜囩被 + ExchangeData exchangeData=new ExchangeData(); + //瑙f瀽鍏朵腑绗﹀悎瑕佹眰鐨勫竵绉嶅浜烘皯甯佺殑姹囩巼 + ExchangeData.Pars_HTML(); + //瀵煎嚭鎴恱ls杩涜杈撳嚭 + ExchangeData.Export_Excel("Rate.xls"); + + } +} diff --git a/ExchangeRata/src/Rate_Record.java b/ExchangeRata/src/Rate_Record.java new file mode 100644 index 0000000..afb2ddc --- /dev/null +++ b/ExchangeRata/src/Rate_Record.java @@ -0,0 +1,62 @@ +/** + 鏋勯犱竴涓眹鐜囪褰曠被锛屼繚瀛樺綋鍓嶆棩鏈熷拰缇庡厓銆佹鍏冦佹腐甯佸浜烘皯甯佺殑姹囩巼锛屽叾涓殑鍑芥暟閫氳繃ALT+Insert蹇嵎閿夋嫨鍔犲叆鍗冲彲 + */ +public class Rate_Record { + private String Hkdcny; //娓竵瀵逛汉姘戝竵姹囩巼 + private String Eurcny; //娆у厓瀵逛汉姘戝竵姹囩巼 + private String Usdcny; //缇庡厓瀵逛汉姘戝竵姹囩巼 + private String date; //褰撳墠璁$畻鐨勬椂闂 + + public Rate_Record() { + } + public Rate_Record(String hkdcny, String eurcny, String usdcny, String date) { + Hkdcny = hkdcny; + Eurcny = eurcny; + Usdcny = usdcny; + this.date = date; + } + + + + public String getEurcny() { + return Eurcny; + } + + public String getHkdcny() { + return Hkdcny; + } + + public String getUsdcny() { + return Usdcny; + } + + public String getDate() { + return date; + } + + public void setHkdcny(String hkdcny) { + Hkdcny = hkdcny; + } + + public void setEurcny(String eurcny) { + Eurcny = eurcny; + } + + public void setUsdcny(String usdcny) { + Usdcny = usdcny; + } + + public void setDate(String date) { + this.date = date; + } + + @Override + public String toString() { + return "Rate_Record{" + + "Hkdcny='" + Hkdcny + '\'' + + ", Eurcny='" + Eurcny + '\'' + + ", Usdcny='" + Usdcny + '\'' + + ", date='" + date + '\'' + + '}'; + } +} diff --git a/Linux2.txt b/Linux2.txt new file mode 100644 index 0000000..877ed06 --- /dev/null +++ b/Linux2.txt @@ -0,0 +1,2 @@ +scp /dir1 root@l-test.dev.cn1:/home/temp +然后提示输入目标主机l-test.dev.cn1的密码就可以进行复制。 diff --git a/README.md b/README.md index 158d27d..2cefc8a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# campus2016 -git repository for qunar students 2016 +# campus2016 +git repository for qunar students 2016 diff --git a/Top10IP.txt b/Top10IP.txt new file mode 100644 index 0000000..7151c19 --- /dev/null +++ b/Top10IP.txt @@ -0,0 +1,10 @@ +cat access.log|awk '{print $1}' access.log|sort |uniq -c|sort -nr|head -n 10 + +cat 浏览access.log日志文件; +awk 是非常棒的数据处理工具,其可以把每条日志中的IP获取; + +uniq -c 合并重复行,并记录重复次数。 + +head -n 10 选出前十; + +sort -nr 按照数字进行倒叙排序。 \ No newline at end of file