Read CSV file using java 8
To understand the code. Please watch my youtube video here
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Stream;
public class Pracs {
public static void main(String[] args) {
Path path = Paths.get("D:\\brijesh projects\\FL_insurance_samplecsv\\FL_insurance_sample.csv");
if(Files.exists(path)){
//read opern
try(Stream<String> stream = Files.lines(path)){
stream.skip(1).limit(10).forEach(System.out::println);
}catch (IOException e){
e.printStackTrace();
}
}else{
System.out.println("File does not exist");
}
}
}
Comments
Post a Comment