public void close() throws IOException {
        try {
            finish();
        } catch (IOException ignored) {
        }
        if (deflater != null) {
            deflater.end();
        }
        super.close();
    }
@Test
    public void testSerializeDataset() throws Exception {
        ObjectOutputStream out = new ObjectOutputStream(
                new FileOutputStream(file));
        try {
            out.writeObject(dataset());
            out.writeUTF("END");
        } finally {
            out.close();
        }
        Attributes dataset = deserializeAttributes();
        assertTrue(dataset.getValue(Tag.PixelData) instanceof BulkData);
        Object fragments = dataset.getValue("DicomOutputStreamTest", 0x99990010);
        assertTrue(fragments instanceof Fragments);
        assertTrue(((Fragments) fragments).get(2) instanceof BulkDataWithPrefix);
    }