From 4623552076b90f28bf8611452914d066c85364cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=E5=98=89=E9=98=B3?= Date: Fri, 20 Apr 2018 17:04:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E6=9C=BA=E7=89=88=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E5=A4=84=E7=90=86=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/workspace.xml | 39 +++++++++++-------- .../java/com/fjy/hadoop/UserAgentTest.java | 16 +++++++- 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 1593cf3..f0dc9ee 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,11 +2,8 @@ - - - - + @@ -32,10 +29,11 @@ - - + + + @@ -534,7 +532,7 @@ - + 1521904777876 @@ -592,13 +590,17 @@ - - - - @@ -626,9 +628,12 @@ + + + - @@ -644,7 +649,7 @@ - + @@ -678,7 +683,8 @@ - @@ -1162,10 +1168,11 @@ - - + + + diff --git a/src/test/java/com/fjy/hadoop/UserAgentTest.java b/src/test/java/com/fjy/hadoop/UserAgentTest.java index cf0e64b..242e414 100644 --- a/src/test/java/com/fjy/hadoop/UserAgentTest.java +++ b/src/test/java/com/fjy/hadoop/UserAgentTest.java @@ -10,6 +10,8 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; +import java.util.HashMap; +import java.util.Map; /** * @author F嘉阳 @@ -26,6 +28,8 @@ public class UserAgentTest { String line = ""; int count = 0; + Map browerMap = new HashMap(); + UserAgentParser userAgentParser = new UserAgentParser(); while (line != null) { @@ -41,13 +45,23 @@ public class UserAgentTest { String os = agent.getOs(); String platform = agent.getPlatform(); boolean mobile = agent.isMobile(); + Integer browserValue = browerMap.get(browser); + if (browserValue != null) { + browerMap.put(browser, browerMap.get(browser) + 1); + } else { + browerMap.put(browser, 1); + } //输出解析的信息 System.out.println(browser + "," + engine + "," + engineVersion + "," + os + "," + platform + "," + mobile); } } - System.out.println("总记录数:"+count); + System.out.println("总记录数:" + count); + System.out.println("===================================="); + for (Map.Entryentry :browerMap.entrySet()){ + System.out.println(entry.getKey()+":"+entry.getValue()); + } } /**