IdentityTemplateLibrary { void store(OutputStream out) throws IOException { BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out)); for (Entry<String, Point2d[]> e : templateMap.entries()) { bw.write(encodeEntry(e)); bw.write('\n'); } bw.close(); } private  IdentityTemplateLibrary(); IdentityTemplateLibrary add(IdentityTemplateLibrary library);  }
@Test public void store() throws IOException { IdentityTemplateLibrary lib = IdentityTemplateLibrary.empty(); lib.add(IdentityTemplateLibrary.decodeEntry("[C][C][O] 0, 1, 2, 3, 4, 5")); lib.add(IdentityTemplateLibrary.decodeEntry("[C][C] 0, 1, 2, 3")); ByteArrayOutputStream baos = new ByteArrayOutputStream(); lib.store(baos); baos.close(); assertThat(new String(baos.toByteArray()), is("[C][C][O] |(.0,1.0,;2.0,3.0,;4.0,5.0,)|\n[C][C] |(.0,1.0,;2.0,3.0,)|\n")); }