1 21 22 27 28 package javax.mail.util; 29 30 import java.io.*; 31 import javax.mail.internet.SharedInputStream ; 32 33 41 42 public class SharedByteArrayInputStream extends ByteArrayInputStream 43 implements SharedInputStream { 44 47 protected int start = 0; 48 49 55 public SharedByteArrayInputStream(byte[] buf) { 56 super(buf); 57 } 58 59 68 public SharedByteArrayInputStream(byte[] buf, int offset, int length) { 69 super(buf, offset, length); 70 start = offset; 71 } 72 73 79 public long getPosition() { 80 return pos - start; 81 } 82 83 95 public InputStream newStream(long start, long end) { 96 if (start < 0) 97 throw new IllegalArgumentException ("start < 0"); 98 if (end == -1) 99 end = count - this.start; 100 return new SharedByteArrayInputStream(buf, 101 this.start + (int)start, (int)(end - start)); 102 } 103 } 104 | Popular Tags |