final POIFSFileSystem poiFs = new POIFSFileSystem();
for (int i = 0; i < psf1.length; i++)
{
final InputStream in =
new ByteArrayInputStream(psf1[i].getBytes());
final PropertySet psIn = PropertySetFactory.create(in);
final MutablePropertySet psOut = new MutablePropertySet(psIn);
final ByteArrayOutputStream psStream =
new ByteArrayOutputStream();
psOut.write(psStream);
psStream.close();
final byte[] streamData = psStream.toByteArray();
poiFs.createDocument(new ByteArrayInputStream(streamData),
psf1[i].getName());
poiFs.writeFilesystem(out);
}
out.close();
/* Read the property set streams from the POI filesystem just
* created. */
final POIFile[] psf2 = Util.readPropertySets(copy);
for (int i = 0; i < psf2.length; i++)
{
final byte[] bytes1 = psf1[i].getBytes();
final byte[] bytes2 = psf2[i].getBytes();
final InputStream in1 = new ByteArrayInputStream(bytes1);
final InputStream in2 = new ByteArrayInputStream(bytes2);
final PropertySet ps1 = PropertySetFactory.create(in1);
final PropertySet ps2 = PropertySetFactory.create(in2);
/* Compare the property set stream with the corresponding one
* from the origin file and check whether they are equal. */
assertEquals("Equality for file " + f.getName(), ps1, ps2);
}