Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- public class Main {
- public static void main(String[] args) {
- // Source of file
- String csvFile = "/Users/srikanth/Downloads/C2ImportGroupsSample.csv";
- BufferedReader br = null;
- String line = "";
- String cvsSplitBy = ",";
- try {
- br = new BufferedReader(new FileReader(csvFile));
- while ((line = br.readLine()) != null) {
- // use comma as separator
- String[] fileds = line.split(cvsSplitBy);
- //let assume the id present at 3rd index
- //let the id to which u want to pass the id
- actionOnid(fileds[3]);
- }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- if (br != null) {
- try {
- br.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
- public static void actionOnid(String id) {
- System.out.println("Use the id-"+id);
- }
- }
Add Comment
Please, Sign In to add comment