/** * Default constructor. */ public POIServiceImpl() { // Just checking a single class in loci.poi.poifs.filesystem package checkClassDependency(loci.poi.poifs.filesystem.DirectoryEntry.class); }
@Override public byte[] getDocumentBytes(String file) throws IOException { return getDocumentBytes(file, getFileSize(file)); }
@Override public byte[] getDocumentBytes(String file, int length) throws IOException { int size = getFileSize(file); int len = length > size ? size : length; byte[] buf = new byte[len]; InputStream s = getInputStream(file); s.read(buf); s.close(); return buf; }
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 RandomAccessInputStream getDocumentStream(String file) throws IOException { return new RandomAccessInputStream(getDocumentBytes(file)); }
@Override public void initialize(String file) throws IOException { initialize(new RandomAccessInputStream(file, MAX_BLOCK_SIZE)); }
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 RandomAccessInputStream getDocumentStream(String file) throws IOException { return new RandomAccessInputStream(getDocumentBytes(file)); }
@Override public void initialize(String file) throws IOException { initialize(new RandomAccessInputStream(file, MAX_BLOCK_SIZE)); }
@Override public byte[] getDocumentBytes(String file, int length) throws IOException { int size = getFileSize(file); int len = length > size ? size : length; byte[] buf = new byte[len]; InputStream s = getInputStream(file); s.read(buf); s.close(); return buf; }
@Override public byte[] getDocumentBytes(String file) throws IOException { return getDocumentBytes(file, getFileSize(file)); }
@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); }
/** * Default constructor. */ public POIServiceImpl() { // Just checking a single class in loci.poi.poifs.filesystem package checkClassDependency(loci.poi.poifs.filesystem.DirectoryEntry.class); }
@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); }