package com.guru99.readers;
import java.io.File;
import java.util.Scanner;
public class CSVReader {
public static void main(String[] args) {
String fileName ="data.csv";
File file = new File(fileName);
try {
Scanner inputStream = new Scanner(file);
System.out.println("Salary");
while(inputStream.hasNext()){
String data = inputStream.next();
String[] values = data.split(",");
System.out.println(values[2]);
//System.out.println(data );
}
inputStream.close();
} catch (Exception e) {
// TODO: handle exception
}
}
}
import java.io.File;
import java.util.Scanner;
public class CSVReader {
public static void main(String[] args) {
String fileName ="data.csv";
File file = new File(fileName);
try {
Scanner inputStream = new Scanner(file);
System.out.println("Salary");
while(inputStream.hasNext()){
String data = inputStream.next();
String[] values = data.split(",");
System.out.println(values[2]);
//System.out.println(data );
}
inputStream.close();
} catch (Exception e) {
// TODO: handle exception
}
}
}
No comments:
Post a Comment