点名器
package com.czie.iot1913.lps.IO.BufferStream;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Random;
/**
* FileName: ChooseName
* Author: lps
* Date: 2022/3/26 17:45
* Sign:刘品水 Q:1944900433
*/
public class RandomChooseName {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new FileReader("F:\\JavaCode\\array.txt"));
ArrayList<Object> array = new ArrayList<>();
Object line;
while ((line= br.readLine())!=null){
array.add(line);
}
br.close();
Random ra = new Random();
int index = ra.nextInt(array.size());
Object name = array.get(index);
System.out.println("幸运者是:"+name);
}
}