| 54 | } |
| 55 | |
| 56 | private static List<String> readTips() throws IOException { |
| 57 | InputStream tipsResource = Thread.currentThread() |
| 58 | .getContextClassLoader() |
| 59 | .getResourceAsStream("tips.txt"); |
| 60 | List<String> tips = new ArrayList<>(); |
| 61 | InputStreamReader reader = new InputStreamReader(tipsResource, Charset.forName("UTF-8")); |
| 62 | try (BufferedReader bufferedReader = new BufferedReader(reader)) { |
| 63 | String line; |
| 64 | while ((line = bufferedReader.readLine()) != null) { |
| 65 | if (line.startsWith("#") || line.isEmpty()) |
| 66 | continue; |
| 67 | tips.add(line); |
| 68 | } |
| 69 | } |
| 70 | return tips; |
| 71 | } |
| 72 | |
| 73 | private static String randomElement(List<String> tips) { |
| 74 | return tips.get(randomInt(tips.size())); |