Class WriteAuthorAndTitle


  • public final class WriteAuthorAndTitle
    extends Object

    This class is a sample application which shows how to write or modify the author and title property of an OLE 2 document. This could be done in two different ways:

    • The first approach is to open the OLE 2 file as a POI filesystem (see class POIFSFileSystem), read the summary information property set (see classes SummaryInformation and PropertySet), write the author and title properties into it and write the property set back into the POI filesystem.

    • The second approach does not modify the original POI filesystem, but instead creates a new one. All documents from the original POIFS are copied to the destination POIFS, except for the summary information stream. The latter is modified by setting the author and title property before writing it to the destination POIFS. It there are several summary information streams in the original POIFS - e.g. in subordinate directories - they are modified just the same.

    This sample application takes the second approach. It expects the name of the existing POI filesystem's name as its first command-line parameter and the name of the output POIFS as the second command-line argument. The program then works as described above: It copies nearly all documents unmodified from the input POI filesystem to the output POI filesystem. If it encounters a summary information stream it reads its properties. Then it sets the "author" and "title" properties to new values and writes the modified summary information stream into the output file.

    Further explanations can be found in the HPSF HOW-TO.

    • Method Detail

      • main

        public static void main​(String[] args)
                         throws IOException

        Runs the example program.

        Parameters:
        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.