It will read a CSV file from a particular path and split the data stored in the CSV file
This code reads a CSV file line by line and uses StringTokenizer to split the lines with a "|" Delimiter
The libraries used are:
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
The following line describes the path of the csv file and the delimiter by which the string needs to be splitted.
List trends = obj.readFile(Paths.get("C:\\test\\sample.csv"), "|");
Submitted by Priyonath Mondal (priyonath)
Download packets of source code on Coders Packet
Comments