I've a file called "integers.csv" where I have 20 million data (type: long). I create this function to store them into a Record class (which has only a long variable). It works, but is very slow because it stores about 1k numbers per second. Are there ways to store it fastly?
private static void loadArray(String filepath, Sorting<Record> orderedArray) throws IOException, SortingException{
System.out.println("\nLoading data from file...\n");
Path inputFilePath = Paths.get(filepath);
try(BufferedReader fileInputReader = Files.newBufferedReader(inputFilePath, ENCODING)){
String line = null;
while((line = fileInputReader.readLine()) != null){
String[] lineElements = line.split("\n");
Record record1 = new Record(Long.parseLong(lineElements[0]));
orderedArray.add(record1);
}
}
System.out.println("\nData loaded\n");
}