private void parseFile(DirectoryEntry r) throws IOException { filePath.add(r.getName()); Iterator iter = r.getEntries(); while (iter.hasNext()) { Entry o = (Entry) iter.next(); boolean isInstance = o.isDirectoryEntry(); boolean isDocument = o.isDocumentEntry(); if (isInstance) parseFile((DirectoryEntry) o); else if (isDocument) { final StringBuilder path = new StringBuilder(); for (String p : filePath) { path.append(p); path.append(File.separator); } path.append(o.getName()); DocumentInputStream s = new DocumentInputStream((DocumentEntry) o, stream); fileSizes.put(path.toString(), s.available()); files.put(path.toString(), (DocumentEntry) o); s.close(); } } filePath.removeElementAt(filePath.size() - 1); }
private void parseFile(DirectoryEntry r) throws IOException { filePath.add(r.getName()); Iterator iter = r.getEntries(); while (iter.hasNext()) { Entry o = (Entry) iter.next(); boolean isInstance = o.isDirectoryEntry(); boolean isDocument = o.isDocumentEntry(); if (isInstance) parseFile((DirectoryEntry) o); else if (isDocument) { final StringBuilder path = new StringBuilder(); for (String p : filePath) { path.append(p); path.append(File.separator); } path.append(o.getName()); DocumentInputStream s = new DocumentInputStream((DocumentEntry) o, stream); fileSizes.put(path.toString(), s.available()); files.put(path.toString(), (DocumentEntry) o); s.close(); } } filePath.removeElementAt(filePath.size() - 1); }
@Override public void initialize(RandomAccessInputStream s) throws IOException { // determine the size of a 'big' block stream = s; stream.order(true); stream.seek(30); int size = (int) Math.pow(2, stream.readShort()); stream.seek(0); // initialize the file system fileSystem = new POIFSFileSystem(stream, size); root = fileSystem.getRoot(); // build the list of files in the file system filePath = new Vector<String>(); fileSizes = new Hashtable<String, Integer>(); files = new Hashtable<String, DocumentEntry>(); parseFile(root); }
@Override public void initialize(RandomAccessInputStream s) throws IOException { // determine the size of a 'big' block stream = s; stream.order(true); stream.seek(30); int size = (int) Math.pow(2, stream.readShort()); stream.seek(0); // initialize the file system fileSystem = new POIFSFileSystem(stream, size); root = fileSystem.getRoot(); // build the list of files in the file system filePath = new Vector<String>(); fileSizes = new Hashtable<String, Integer>(); files = new Hashtable<String, DocumentEntry>(); parseFile(root); }