1 package org.sapia.ubik.util; 2 3 import java.io.IOException ; 4 import java.io.InputStream ; 5 6 7 27 public class ByteVectorInputStream extends InputStream { 28 29 private ByteVector _bytes; 30 31 public ByteVectorInputStream(ByteVector bytes){ 32 _bytes = bytes; 33 } 34 public ByteVector getByteVector(){ 35 return _bytes; 36 } 37 38 41 public int available() throws IOException { 42 return _bytes.remaining(); 43 } 44 45 48 public void close() throws IOException { 49 } 50 51 54 public synchronized void mark(int readlimit) { 55 _bytes.mark(readlimit); 56 } 57 58 61 public boolean markSupported() { 62 return true; 63 } 64 65 68 public int read() throws IOException { 69 return _bytes.read(); 70 } 71 72 75 public int read(byte[] b, int off, int len) throws IOException { 76 int read = _bytes.read(b, off, len); 77 return read == 0 ? -1 : read; 78 } 79 80 83 public int read(byte[] b) throws IOException { 84 int read = _bytes.read(b); 85 return read == 0 ? -1 : read; 86 } 87 88 91 public synchronized void reset() throws IOException { 92 _bytes.reset(); 93 } 94 95 98 public long skip(long n) throws IOException { 99 return _bytes.skip(n); 100 } 101 } 102 | Popular Tags |