Mirror the contents of a given test state in a given directory. @param state @param dir @throws IOException
(Map<Trie, TextFile> state, Path dir)
| 198 | * @throws IOException |
| 199 | */ |
| 200 | public static void mirror(Map<Trie, TextFile> state, Path dir) throws IOException { |
| 201 | for (Map.Entry<Trie, TextFile> e : state.entrySet()) { |
| 202 | Path p = dir.resolve(e.getKey().toPath()); |
| 203 | TextFile f = e.getValue(); |
| 204 | // |
| 205 | p.getParent().toFile().mkdirs(); |
| 206 | try (FileOutputStream fout = new FileOutputStream(p.toFile())) { |
| 207 | fout.write(f.getBytes(StandardCharsets.US_ASCII)); |
| 208 | } |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * Force a directory and all its contents to be deleted. |