New method toInputStream() added.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353331 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5b6df1dd86
commit
0f1a7a40b6
@ -54,10 +54,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.poi.hpsf;
|
package org.apache.poi.hpsf;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
import org.apache.poi.util.LittleEndianConsts;
|
import org.apache.poi.util.LittleEndianConsts;
|
||||||
|
|
||||||
@ -240,4 +244,30 @@ public class MutablePropertySet extends PropertySet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Returns the contents of this property set stream as an input stream.
|
||||||
|
* The latter can be used for example to write the property set into a POIFS
|
||||||
|
* document. The input stream represents a snapshot of the property set.
|
||||||
|
* If the latter is modified while the input stream is still being
|
||||||
|
* read, the modifications will not be reflected in the input stream but in
|
||||||
|
* the {@link MutablePropertySet} only.</p>
|
||||||
|
*
|
||||||
|
* @return the contents of this property set stream
|
||||||
|
*
|
||||||
|
* @throws WritingNotSupportedException if HPSF does not yet support writing
|
||||||
|
* of a property's variant type.
|
||||||
|
* @throws IOException if an I/O exception occurs.
|
||||||
|
*/
|
||||||
|
public InputStream toInputStream()
|
||||||
|
throws IOException, WritingNotSupportedException
|
||||||
|
{
|
||||||
|
final ByteArrayOutputStream psStream = new ByteArrayOutputStream();
|
||||||
|
write(psStream);
|
||||||
|
psStream.close();
|
||||||
|
final byte[] streamData = psStream.toByteArray();
|
||||||
|
return new ByteArrayInputStream(streamData);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user