1 2 17 18 19 package org.apache.poi.contrib.poibrowser; 20 21 import java.io.*; 22 import org.apache.poi.poifs.filesystem.*; 23 24 35 public class DocumentDescriptor 36 { 37 String name; 38 POIFSDocumentPath path; 39 DocumentInputStream stream; 40 41 int size; 42 byte[] bytes; 43 44 45 57 public DocumentDescriptor(final String name, 58 final POIFSDocumentPath path, 59 final DocumentInputStream stream, 60 final int nrOfBytes) 61 { 62 this.name = name; 63 this.path = path; 64 this.stream = stream; 65 try 66 { 67 size = stream.available(); 68 if (stream.markSupported()) 69 { 70 stream.mark(nrOfBytes); 71 final byte[] b = new byte[nrOfBytes]; 72 final int read = stream.read(b, 0, Math.min(size, b.length)); 73 bytes = new byte[read]; 74 System.arraycopy(b, 0, bytes, 0, read); 75 stream.reset(); 76 } 77 } 78 catch (IOException ex) 79 { 80 System.out.println(ex); 81 } 82 } 83 84 } 85 | Popular Tags |