*/
package org.apache.poi.hpsf.examples;
-import java.io.*;
-import java.util.*;
-import org.apache.poi.hpsf.*;
-import org.apache.poi.poifs.eventfilesystem.*;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.poi.hpsf.NoPropertySetStreamException;
+import org.apache.poi.hpsf.Property;
+import org.apache.poi.hpsf.PropertySet;
+import org.apache.poi.hpsf.PropertySetFactory;
+import org.apache.poi.hpsf.Section;
+import org.apache.poi.poifs.eventfilesystem.POIFSReader;
+import org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent;
+import org.apache.poi.poifs.eventfilesystem.POIFSReaderListener;
import org.apache.poi.util.HexDump;
/**
public class ReadCustomPropertySets
{
- public static void main(String[] args)
+ /**
+ * <p>Runs the example program.</p>
+ *
+ * @param args Command-line arguments (unused).
+ * @throws IOException if any I/O exception occurs.
+ */
+ public static void main(final String[] args)
throws IOException
{
final String filename = args[0];
static class MyPOIFSReaderListener implements POIFSReaderListener
{
- public void processPOIFSReaderEvent(POIFSReaderEvent event)
+ public void processPOIFSReaderEvent(final POIFSReaderEvent event)
{
PropertySet ps = null;
try
{
/* Print a single property: */
Property p = properties[i2];
- int id = p.getID();
+ long id = p.getID();
long type = p.getType();
Object value = p.getValue();
out(" Property ID: " + id + ", type: " + type +
System.out.println(msg);
}
- static String hex(byte[] bytes)
+ static String hex(final byte[] bytes)
{
return HexDump.dump(bytes, 0L, 0);
}
*/
package org.apache.poi.hpsf.examples;
-import java.io.*;
-import org.apache.poi.hpsf.*;
-import org.apache.poi.poifs.eventfilesystem.*;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+import org.apache.poi.hpsf.PropertySetFactory;
+import org.apache.poi.hpsf.SummaryInformation;
+import org.apache.poi.poifs.eventfilesystem.POIFSReader;
+import org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent;
+import org.apache.poi.poifs.eventfilesystem.POIFSReaderListener;
/**
* <p>Sample application showing how to read a OLE 2 document's
*/
public class ReadTitle
{
-
- public static void main(String[] args) throws IOException
+ /**
+ * <p>Runs the example program.</p>
+ *
+ * @param args Command-line arguments. The first command-line argument must
+ * be the name of a POI filesystem to read.
+ * @throws IOException if any I/O exception occurs.
+ */
+ public static void main(final String[] args) throws IOException
{
final String filename = args[0];
POIFSReader r = new POIFSReader();
static class MyPOIFSReaderListener implements POIFSReaderListener
{
- public void processPOIFSReaderEvent(POIFSReaderEvent event)
+ public void processPOIFSReaderEvent(final POIFSReaderEvent event)
{
SummaryInformation si = null;
try
<body>
<div>
- Horrible PropertySet Format API reads things like Document Summary info from
- OLE 2 Compound document files.
<p>Processes streams in the Horrible Property Set Format (HPSF) in POI
filesystems. Microsoft Office documents, i.e. POI filesystems, usually
contain meta data like author, title, last editing date etc. These items
si.setProperty(p);
si.setProperty(PropertyIDMap.PID_TITLE, Variant.VT_LPSTR, TITLE);
- final ByteArrayOutputStream psStream = new ByteArrayOutputStream();
- ps.write(psStream);
- psStream.close();
- final byte[] streamData = psStream.toByteArray();
- poiFs.createDocument(new ByteArrayInputStream(streamData),
+ poiFs.createDocument(ps.toInputStream(),
SummaryInformation.DEFAULT_STREAM_NAME);
poiFs.writeFilesystem(out);
out.close();
final POIFSReader r = new POIFSReader();
r.registerListener(new POIFSReaderListener()
{
- public void processPOIFSReaderEvent(final POIFSReaderEvent event)
+ public void processPOIFSReaderEvent
+ (final POIFSReaderEvent event)
{
try
{