Hi
I am trying to read the a string that shows the version name from a text file and print it. I only want to print the string once as it occurs a few times in the text log file. I managed it with the code below that should do it but keep it compilation errors. the string I am interested in the file is as follow: Version software 219 build. The error I am getting is: The constructor FileReader(String) is undefined
Can anyone check how to fix it and if it work on their set up?Code:Map<String,Integer> map=new HashMap<String, Integer>(); FileReader freader = new FileReader("C:\\abc.log"); BufferedReader br = new BufferedReader(freader); String s, t = ""; while((s = br.readLine()) != null) { t = t + s; } freader.close(); String b[] = t.split("\n"); int j = 0; while(j < b.length) { String c[] = b[j].split(" "); for(int i = 0; i < c.length; i++) { if(c[i].equals("Version")) { String r = ""; for(int k = i; k < i+4; k++) r = r + c[k] + " "; map.put(r, j); } } j++; } Map<String, Integer> mapResult; for (Entry<String, Integer> entry : mapResult.entrySet()) { String distance = entry.getKey(); Integer value = entry.getValue(); System.out.println(entry.getKey()); } }![]()




Reply With Quote
