use of org.apache.poi.poifs.filesystem.POIFSFileSystem in project poi by apache.
the class HPBFFileHandler method handleFile.
@Override
public void handleFile(InputStream stream, String path) throws Exception {
HPBFDocument pub = new HPBFDocument(new POIFSFileSystem(stream));
assertNotNull(pub.getEscherDelayStm());
assertNotNull(pub.getMainContents());
assertNotNull(pub.getQuillContents());
// writing is not yet implemented... handlePOIDocument(pub);
pub.close();
}
use of org.apache.poi.poifs.filesystem.POIFSFileSystem in project poi by apache.
the class HPSFPropertiesOnlyDocument method write.
/**
* Write out, with any properties changes, but nothing else
*/
public void write(File newFile) throws IOException {
POIFSFileSystem fs = POIFSFileSystem.create(newFile);
try {
write(fs);
fs.writeFilesystem();
} finally {
fs.close();
}
}
use of org.apache.poi.poifs.filesystem.POIFSFileSystem in project poi by apache.
the class EmbeddedExtractor method extract.
protected EmbeddedData extract(DirectoryNode dn) throws IOException {
assert (canExtract(dn));
ByteArrayOutputStream bos = new ByteArrayOutputStream(20000);
POIFSFileSystem dest = new POIFSFileSystem();
try {
copyNodes(dn, dest.getRoot());
// start with a reasonable big size
dest.writeFilesystem(bos);
} finally {
dest.close();
}
return new EmbeddedData(dn.getName(), bos.toByteArray(), CONTENT_TYPE_BYTES);
}
use of org.apache.poi.poifs.filesystem.POIFSFileSystem in project poi by apache.
the class EncryptionUtils method decrypt.
public static InputStream decrypt(final InputStream inputStream, final String pwd) throws Exception {
try {
POIFSFileSystem fs = new POIFSFileSystem(inputStream);
EncryptionInfo info = new EncryptionInfo(fs);
Decryptor d = Decryptor.getInstance(info);
if (!d.verifyPassword(pwd)) {
throw new RuntimeException("incorrect password");
}
return d.getDataStream(fs);
} finally {
IOUtils.closeQuietly(inputStream);
}
}
use of org.apache.poi.poifs.filesystem.POIFSFileSystem in project poi by apache.
the class HSLFSlideShowImpl method write.
/**
* Writes out the slideshow file the is represented by an instance
* of this class.
* If you require all streams to be written out (eg Marcos, embeded
* documents), then set <code>preserveNodes</code> set to <code>true</code>
*
* @param out The OutputStream to write to.
* @param preserveNodes Should all OLE2 streams be written back out, or only the common ones?
* @throws IOException If there is an unexpected IOException from
* the passed in OutputStream
*/
public void write(OutputStream out, boolean preserveNodes) throws IOException {
// Get a new FileSystem to write into
POIFSFileSystem outFS = new POIFSFileSystem();
try {
// Write into the new FileSystem
write(outFS, preserveNodes);
// Send the POIFSFileSystem object out to the underlying stream
outFS.writeFilesystem(out);
} finally {
outFS.close();
}
}
Aggregations