public static ArrayList<Long> calculateFileSplit(String filePath, int chunkSize) throws IOException {
        RandomAccessFile raFile = null;
        ArrayList<Long> split = new ArrayList<Long>();
        try {
            raFile = new RandomAccessFile(filePath, "r");
            long currentPointer = 0L;
            long fileSize = raFile.length();
            String tmp = null;
            Long lastPointer = 0L;
            split.add(0L);
            System.out.println("Start scanning file...");
            do {
                tmp = raFile.readLine();
                if (tmp != null) {
                    tmp += '\n';
                    int increment = tmp.getBytes().length;
                    if (increment > chunkSize) {
                        throw new IOException("Data row is too long...");
                    }
                    if (currentPointer - lastPointer + increment <= chunkSize) { 
                        currentPointer += increment;
                    } else {
                        split.add(currentPointer);            //starting point of next chunk
                        System.out.println("Scanning file... " + (int)((1.0d * currentPointer / fileSize) * 100) + "% finished.");
                        lastPointer = currentPointer;
                        currentPointer += increment;
                    }
                } else {    //reach the end of file
                    if (tmp == null && currentPointer != lastPointer) {
                        split.add(currentPointer);
                        System.out.println("Finished scanning file.");
                    }
                }
            } while (tmp != null);
        } catch (FileNotFoundException e) {
            throw new IOException(e.toString());
        } catch (IOException e) {
            throw new IOException(e.toString());
        } finally {
            try {
                raFile.close();
            } catch (IOException e) {
                throw new IOException(e.toString());
            }
        }
        return split;
    }