Guest User

Untitled

a guest
Aug 16th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.FileNotFoundException;
  3. import java.io.FileReader;
  4. import java.io.IOException;
  5.  
  6. public class Main {
  7.  
  8. public static void main(String[] args) {
  9. // Source of file
  10. String csvFile = "/Users/srikanth/Downloads/C2ImportGroupsSample.csv";
  11. BufferedReader br = null;
  12. String line = "";
  13. String cvsSplitBy = ",";
  14.  
  15. try {
  16.  
  17. br = new BufferedReader(new FileReader(csvFile));
  18. while ((line = br.readLine()) != null) {
  19.  
  20. // use comma as separator
  21. String[] fileds = line.split(cvsSplitBy);
  22.  
  23. //let assume the id present at 3rd index
  24. //let the id to which u want to pass the id
  25. actionOnid(fileds[3]);
  26.  
  27. }
  28.  
  29. } catch (FileNotFoundException e) {
  30. e.printStackTrace();
  31. } catch (IOException e) {
  32. e.printStackTrace();
  33. } finally {
  34. if (br != null) {
  35. try {
  36. br.close();
  37. } catch (IOException e) {
  38. e.printStackTrace();
  39. }
  40. }
  41. }
  42.  
  43. }
  44.  
  45. public static void actionOnid(String id) {
  46.  
  47. System.out.println("Use the id-"+id);
  48. }
  49.  
  50. }
Add Comment
Please, Sign In to add comment