import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Random;
class Maoxian {
public static void main(String[] args) throws IOException,
InterruptedException{
getQuestion("大冒险.txt", "大冒险问题是:");
//getQuestion("中奖名单.txt", " 恭喜....");
}
@SuppressWarnings("deprecation")
public static void getQuestion(String fileName, String str) throws IOException,
InterruptedException {
ArrayList<String> list = new ArrayList<String>();
BufferedReader br = new BufferedReader(new FileReader(fileName));
String line = null;
while ((line = br.readLine()) != null) {
list.add(line);
}
Random random = new Random();
int num = random.nextInt(list.size() - 1) + 1;
System.out.print(str);
Runnable r = new Runnable() {
public void run() {
while (true) {
try {
Thread.sleep(150);
System.out.print(".");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
Thread t = new Thread(r);
t.start();
Thread.sleep(2500);
t.stop();
String bbtName = list.get(num);
System.out.println("\r\n \t\t" + bbtName);
System.out.println();
}
}
|