Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1.  
  2. package csvreader;
  3.  
  4. import java.io.BufferedReader;
  5. import java.io.File;
  6. import java.io.FileNotFoundException;
  7. import java.io.FileReader;
  8. import java.io.IOException;
  9.  
  10.  
  11. public class CSVReader {
  12.  
  13.  
  14. public static void main(String[] args) throws IOException
  15. {
  16. String[][] users = CSVReader("./users.csv");
  17. //String[][] item = CSVReader(*./item*);
  18. }
  19.  
  20. public static String[][] CSVReader(String fileName) throws FileNotFoundException, IOException
  21. {
  22. String[][] maindata = new String[21][2];
  23. File file = new File(fileName);
  24. BufferedReader br = new BufferedReader(new FileReader(file));
  25. String st;
  26. int counter = 0;
  27. while ((st = br.readLine()) != null)
  28. {
  29. String[] data = st.split(",");
  30. maindata[counter] = data;
  31. counter++;
  32. }
  33. return maindata;
  34. }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement