| 25 | } |
| 26 | |
| 27 | private static byte[] generate(int size) throws IOException { |
| 28 | ByteArrayOutputStream out = new ByteArrayOutputStream(size * 17); |
| 29 | for (int i = 0; i < size; i++) { |
| 30 | int length = ThreadLocalRandom.current().nextInt(1, 9); |
| 31 | byte[] b = new byte[length]; |
| 32 | ThreadLocalRandom.current().nextBytes(b); |
| 33 | String key = Base64.getEncoder().encodeToString(b); |
| 34 | long value = ThreadLocalRandom.current().nextLong(1000000); |
| 35 | out.write((key + ": " + value + "\n").getBytes(StandardCharsets.ISO_8859_1)); |
| 36 | } |
| 37 | return out.toByteArray(); |
| 38 | } |
| 39 | |
| 40 | public Map<String, Long> readMap(InputStream in) throws IOException { |
| 41 | Map<String, Long> map = new HashMap<>(); |