1 2 17 18 19 package org.apache.poi.poifs.dev; 20 21 import java.io.*; 22 23 import java.util.*; 24 25 import org.apache.poi.poifs.filesystem.POIFSFileSystem; 26 27 32 33 public class POIFSViewer 34 { 35 36 41 42 public static void main(final String args[]) 43 { 44 if (args.length < 0) 45 { 46 System.err.println("Must specify at least one file to view"); 47 System.exit(1); 48 } 49 boolean printNames = (args.length > 1); 50 51 for (int j = 0; j < args.length; j++) 52 { 53 viewFile(args[ j ], printNames); 54 } 55 } 56 57 private static void viewFile(final String filename, 58 final boolean printName) 59 { 60 if (printName) 61 { 62 StringBuffer flowerbox = new StringBuffer (); 63 64 flowerbox.append("."); 65 for (int j = 0; j < filename.length(); j++) 66 { 67 flowerbox.append("-"); 68 } 69 flowerbox.append("."); 70 System.out.println(flowerbox); 71 System.out.println("|" + filename + "|"); 72 System.out.println(flowerbox); 73 } 74 try 75 { 76 POIFSViewable fs = 77 new POIFSFileSystem(new FileInputStream(filename)); 78 List strings = POIFSViewEngine.inspectViewable(fs, true, 79 0, " "); 80 Iterator iter = strings.iterator(); 81 82 while (iter.hasNext()) 83 { 84 System.out.print(iter.next()); 85 } 86 } 87 catch (IOException e) 88 { 89 System.out.println(e.getMessage()); 90 } 91 } 92 } 94 | Popular Tags |