我有一個ArrayList的URL作爲它的字符串。我想查找不同主機網站的列表以及顯示的次數。 例如,如果在我的列表中有5個鏈接到谷歌我想統計他們全部。我是通過列表中的每個URL開始一個循環迭代:如何從java中的urls數組列表中獲取主機站點列表和每個主機實例?
for(int i = 0;i<list.size(); i++){
//for every url at i identify the host site and put in hashmap where the key is the
//host site and the variable is the number of URL's from that host
}
我怎麼會從指定URL字符串的URL的主機(如google.com)。我不知道如何編碼那部分。
只是好奇,我會打印出散列表內容。我正在嘗試,但似乎無法正確執行。謝謝btw – user1835504 2013-04-24 18:08:56
@ user1835504只是編輯我的答案,打印出散列表。 – TheEwook 2013-04-24 18:14:03