FileDocCategorySizeDatePackage
POIFSViewer.javaAPI DocApache Poi 3.0.12839Mon Jan 01 12:39:36 GMT 2007org.apache.poi.poifs.dev

POIFSViewer

public class POIFSViewer extends Object
A simple viewer for POIFS files
author
Marc Johnson (mjohnson at apache dot org)

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)
Display the contents of multiple POIFS files

param
args the names of the files to be displayed

        if (args.length < 0)
        {
            System.err.println("Must specify at least one file to view");
            System.exit(1);
        }
        boolean printNames = (args.length > 1);

        for (int j = 0; j < args.length; j++)
        {
            viewFile(args[ j ], printNames);
        }
    
private static voidviewFile(java.lang.String filename, boolean printName)

        if (printName)
        {
            StringBuffer flowerbox = new StringBuffer();

            flowerbox.append(".");
            for (int j = 0; j < filename.length(); j++)
            {
                flowerbox.append("-");
            }
            flowerbox.append(".");
            System.out.println(flowerbox);
            System.out.println("|" + filename + "|");
            System.out.println(flowerbox);
        }
        try
        {
            POIFSViewable fs      =
                new POIFSFileSystem(new FileInputStream(filename));
            List          strings = POIFSViewEngine.inspectViewable(fs, true,
                                        0, "  ");
            Iterator      iter    = strings.iterator();

            while (iter.hasNext())
            {
                System.out.print(iter.next());
            }
        }
        catch (IOException e)
        {
            System.out.println(e.getMessage());
        }