Advertisement
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;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.List;
- import java.util.Random;
- public class PickRandom {
- public static void main(String[] args) {
- List<List<String>> records = new ArrayList<>();
- try (BufferedReader br = new BufferedReader(new FileReader("C:\\Documenti\\Home\\randomcsv\\src\\Cartel1.csv"))) {
- String line;
- while ((line = br.readLine()) != null) {
- String[] values = line.split(",");
- records.add(Arrays.asList(values));
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- Random rand = new Random();
- int n = rand.nextInt(679);
- int n1 = n-1;
- System.out.println(records.get(n-1));
- System.out.println(records.get(n));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement