時指數走出束縛我有我的txt文件裏的數據sotre的列表,它會像下面
陣列劈裂字符串
"[email protected]","10.9.2.34"
"[email protected]","10.9.2.34"
"[email protected]","10.9.2.34"
"[email protected]","10.9.2.34"
"[email protected]","10.9.2.34"
"[email protected]","10.9.2.34"
我會閱讀所有的輸入我的txt文件中,並存儲成DailyFileData
。在那之後,我想從數據中提取出IP address
和gmail.com
,但是我無法做到這一點。mail1
變量將存儲"[email protected]","10.9.2.34"
從txt文件我已經搜索多個解決方案,以便如何在stackoverflow和其他網站中指定兩個分隔符。但我正在逐漸出現在下面的代碼行
String IP1 = Emaildata1[1];
這裏ArrayIndexOutOfboundException
.The錯誤是我的源代碼
for(int c = DailyFileData.size()-1;c>=0;c--)
{
String mail1 = DailyFileData.get(c);
MailCount1 = Collections.frequency(DailyFileData,mail1);
System.out.println("Count of mail is :"+MailCount1);
String filename1 = f.getCanonicalPath();
Pattern pattern = Pattern.compile("\\d{4}-\\d{2}-\\d{2}");
Matcher match = pattern.matcher((CharSequence) filename1);
while (match.find())
{
date1 = match.group(0);
}
String [] Emaildata1 = mail1.split(CSVSplitBy);
System.out.println(Emaildata1);
String domain1 = Emaildata1 [0];
String IP1 = Emaildata1[1];
String [] domainArray1 = domain1.split(emailSplitBy);
String domain2 = domainArray1[0];
System.out.println("The extracted domain is :"+domain2);
System.out.println("The extracted date is :"+date1);
System.out.println("The extracted IP is :"+IP1);
domainAndCounting1.add(domain1);
domainAndCounting1.add(String.valueOf(MailCount1));
Iterator<String> it = DailyFileData.iterator();
while(it.hasNext())
{
String mail2 = it.next();
if(mail2.equals(mail1))
{
it.remove();
c--;
}
}
}
'mail1'的值是多少? –
mail1是存儲ip地址和電子郵件ID的變量 – Lokesh
是的,mail1將存儲IP和電子郵件地址,我已附上我的完整代碼 – yumi