List of usage examples for org.apache.poi.poifs.filesystem DocumentInputStream mark
@Override
public void mark(int ignoredReadlimit)
From source file:nz.govt.natlib.adapter.excel.DocumentDataSource.java
License:Apache License
public DocumentDataSource(DocumentInputStream input) { this.input = input; // Mark the start of the file input.mark(0); }
From source file:poi.poifs.poibrowser.DocumentDescriptor.java
License:Apache License
/** * <p>Creates a {@link DocumentDescriptor}.</p> * * @param name The stream's name.//from ww w . ja v a 2 s . c o m * * @param path The stream's path in the POI filesystem hierarchy. * * @param stream The stream. * * @param nrOfBytes The maximum number of bytes to display in a * dump starting at the beginning of the stream. */ public DocumentDescriptor(final String name, final POIFSDocumentPath path, final DocumentInputStream stream, final int nrOfBytes) { this.name = name; this.path = path; this.stream = stream; try { size = stream.available(); if (stream.markSupported()) { stream.mark(nrOfBytes); final byte[] b = new byte[nrOfBytes]; final int read = stream.read(b, 0, Math.min(size, b.length)); bytes = new byte[read]; System.arraycopy(b, 0, bytes, 0, read); stream.reset(); } } catch (IOException ex) { System.out.println(ex); } }