Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.time.*;
- import java.util.*;
- public class CsvParseMithun {
- public static void main(String[] args) {
- var startTime = Instant.now();
- String filePath = "/Users/amitsen01ei/Downloads/uuids-medium.csv";
- var frequencyMap = new HashMap<Character, Integer>();
- try (var reader = new BufferedReader(new FileReader(filePath))) {
- String line;
- while ((line = reader.readLine()) != null) {
- String[] fields = line.split(",");
- for (var field : fields) {
- for (var ch : field.toCharArray()) {
- frequencyMap.merge(ch, 1, Integer::sum);
- }
- }
- }
- } catch (IOException e) {
- System.err.println(e.getMessage());
- }
- frequencyMap.forEach((key, value) -> System.out.println(STR."\{key} = \{value}"));
- long executionTime = Duration.between(startTime, Instant.now()).getSeconds();
- System.out.println(STR."Execution Time: \{executionTime} s");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement