import java.io.*;
import java.util.*;
public class lineCount {
public static void main(String[] args) {
Map<String,Integer> countMap= new HashMap<String,Integer>();
try (BufferedReader br= new BufferedReader(new FileReader(new File("error.txt"))))
{
String data="";
while ((data=br.readLine())!=null) {
if(countMap.containsKey(data)) {
countMap.put(data, countMap.get(data)+1);
}else {
countMap.put(data, 1);
}
}
countMap.forEach((k,v)->{System.out.println("Error: "+k+" Occurs "+v+" times.");});
} catch (IOException e) {
e.printStackTrace();
}
}
}
I have the text file as below and I want to count duplicate lines by ignoring date and time in line.if date and time is not there then ok if there is date and time means we have to ignore and count.
I did all the thing but i don't know how to ignore date and time.can any one help me
text file
ERROR [CompactionExecutor:21454] 2018-10-29 12:02:41,906 NoSpamLogger.java:91 - Maximum memory usage reached (125.000MiB), cannot allocate chunk of 1.000MiB
ERROR [CompactionExecutor:21454] 2018-10-29 12:02:41,906 NoSpamLogger.java:91 - Maximum memory usage reached (125.000MiB), cannot allocate chunk of 1.000MiB
ERROR [CompactionExecutor:21454] 2018-10-29 12:02:41,906 NoSpamLogger.java:91 - Maximum memory usage reached (125.000MiB), cannot allocate chunk of 1.000MiB
ERROR [CompactionExecutor:21454] 2018-10-29 12:02:41,906 NoSpamLogger.java:91 - Maximum memory usage reached (125.000MiB), cannot allocate chunk of 1.000MiB
ERROR [CompactionExecutor:21454] 2018-10-29 12:02:41,906 NoSpamLogger.java:91 - Maximum memory usage reached (125.000MiB), cannot allocate chunk of 1.000MiB
2018-09-20 14:08:14.571 [main] ERROR org.apache.flink.yarn.YarnApplicationMasterRunner - -Dlogback.configurationFile=file:logback.xml
2018-09-20 14:08:14.571 [main] ERROR org.apache.flink.yarn.YarnApplicationMasterRunner - -Dlogback.configurationFile=file:logback.xml
ERROR [CompactionExecutor:21454] 2018-10-29 12:02:41,906 NoSpamLogger.java:91 - Maximum memory usage reached (125.000MiB), cannot allocate chunk of 1.000MiB
ERROR [CompactionExecutor:21454] 2018-10-29 12:02:41,906 NoSpamLogger.java:91 - Maximum memory usage reached (125.000MiB), cannot allocate chunk of 1.000MiB
ERROR [CompactionExecutor:21454] 2018-10-29 12:02:41,906 NoSpamLogger.java:91 - Maximum memory usage reached (125.000MiB), cannot allocate chunk of 1.000MiB
2018-10-29T12:01:00Z E! Error in plugin [inputs.openldap]: LDAP Result Code 32 "No Such Object":
2018-10-29T12:01:00Z E! Error in plugin [inputs.openldap]: LDAP Result Code 32 "No Such Object":
2018-10-29T12:01:00Z E! Error in plugin [inputs.openldap]: LDAP Result Code 32 "No Such Object":
2018-10-29T12:01:00Z E! Error in plugin [inputs.openldap]: LDAP Result Code 32 "No Such Object":
2018-10-29T12:01:00Z E! Error in plugin [inputs.openldap]: LDAP Result Code 32 "No Such Object":
2018-10-29T12:01:00Z E! Error in plugin [inputs.openldap]: LDAP Result Code 32 "No Such Object":
2018-10-29T12:01:00Z E! Error in plugin [inputs.openldap]: LDAP Result Code 32 "No Such Object":
2018-10-29T12:01:00Z E! Error in plugin [inputs.openldap]: LDAP Result Code 32 "No Such Object":
ERROR [CompactionExecutor:21454] 2018-10-29 12:02:41,906 NoSpamLogger.java:91 - Maximum memory usage reached (125.000MiB), cannot allocate chunk of 1.000MiB
2018-09-20 14:08:14.571 [main] ERROR org.apache.flink.yarn.YarnApplicationMasterRunner - -Dlogback.configurationFile=file:logback.xml
2018-09-20 14:08:14.571 [main] ERROR org.apache.flink.yarn.YarnApplicationMasterRunner - -Dlogback.configurationFile=file:logback.xml
2018-09-20 14:08:14.571 [main] ERROR org.apache.flink.yarn.YarnApplicationMasterRunner - -Dlogback.configurationFile=file:logback.xml
2018-09-20 14:08:14.571 [main] ERROR org.apache.flink.yarn.YarnApplicationMasterRunner - -Dlogback.configurationFile=file:logback.xml
2018-09-20 14:08:14.571 [main] ERROR org.apache.flink.yarn.YarnApplicationMasterRunner - -Dlogback.configurationFile=file:logback.xml
"2018-10-16 19:54:26.691 [RawEventProcessor (2/2)] ERROR com.qolsys.iqcloud.processing.operators.RawEventProcessor1 - processRawPanelEvent():: SerialNumber systemSerialNumber: QV01D173700428AD is not mapped to any meid. {}",2
"2018-10-16 19:54:27.074 [RawEventProcessor (2/2)] ERROR com.qolsys.iqcloud.processing.operators.RawEventProcessor1 - processRawPanelEvent():: SerialNumber systemSerialNumber: QV01D173700428AD is not mapped to any meid. {}",2
"2018-10-16 19:54:27.293 [RawEventProcessor (2/2)] ERROR com.qolsys.iqcloud.processing.operators.RawEventProcessor1 - processRawPanelEvent():: SerialNumber systemSerialNumber: QV01D173700428AD is not mapped to any meid. {}",2
"2018-10-16 19:54:27.296 [RawEventProcessor (2/2)] ERROR com.qolsys.iqcloud.processing.operators.RawEventProcessor1 - processRawPanelEvent():: SerialNumber systemSerialNumber: QV01D173700428AD is not mapped to any meid. {}",2
"2018-10-16 19:54:27.471 [RawEventProcessor (2/2)] ERROR com.qolsys.iqcloud.processing.operators.RawEventProcessor1 - processRawPanelEvent():: SerialNumber systemSerialNumber: QV01D173700428AD is not mapped to any meid. {}",2
"2018-10-16 19:54:27.570 [RawEventProcessor (2/2)] ERROR com.qolsys.iqcloud.processing.operators.RawEventProcessor1 - processRawPanelEvent():: SerialNumber systemSerialNumber: QV01D173700428AD is not mapped to any meid. {}",2
"2018-10-16 19:54:27.574 [RawEventProcessor (2/2)] ERROR com.qolsys.iqcloud.processing.operators.RawEventProcessor1 - processRawPanelEvent():: SerialNumber systemSerialNumber: QV01D173700428AD is not mapped to any meid. {}",2
"2018-10-16 19:54:27.574 [RawEventProcessor (2/2)] ERROR com.qolsys.iqcloud.processing.operators.RawEventProcessor1 - processRawPanelEvent():: SerialNumber systemSerialNumber: QV01D173700428BD is not mapped to any meid. {}",2
"2018-10-16 19:54:27.574 [RawEventProcessor (2/2)] ERROR com.qolsys.iqcloud.processing.operators.RawEventProcessor1 - processRawPanelEvent():: SerialNumber systemSerialNumber: QV01D173700428BD is not mapped to any meid. {}",2