Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 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. import java.util.ArrayList;
  6. import java.util.Arrays;
  7. import java.util.List;
  8. import java.util.Random;
  9.  
  10.  
  11. public class PickRandom {
  12.  
  13. public static void main(String[] args) {
  14. List<List<String>> records = new ArrayList<>();
  15. try (BufferedReader br = new BufferedReader(new FileReader("C:\\Documenti\\Home\\randomcsv\\src\\Cartel1.csv"))) {
  16. String line;
  17. while ((line = br.readLine()) != null) {
  18. String[] values = line.split(",");
  19. records.add(Arrays.asList(values));
  20. }
  21. } catch (IOException e) {
  22. e.printStackTrace();
  23. }
  24.  
  25. Random rand = new Random();
  26. int n = rand.nextInt(679);
  27. int n1 = n-1;
  28. System.out.println(records.get(n-1));
  29. System.out.println(records.get(n));
  30.  
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement