1 23 package org.archive.io; 24 25 26 import java.io.IOException ; 27 28 29 41 public class OriginSeekInputStream extends SeekInputStream { 42 43 44 47 final private SeekInputStream input; 48 49 50 54 final private long origin; 55 56 57 64 public OriginSeekInputStream(SeekInputStream input, long origin) 65 throws IOException { 66 this.input = input; 67 this.origin = origin; 68 input.position(origin); 69 } 70 71 72 @Override 73 public int available() throws IOException { 74 return input.available(); 75 } 76 77 78 @Override 79 public int read() throws IOException { 80 return input.read(); 81 } 82 83 84 @Override 85 public int read(byte[] buf, int ofs, int len) throws IOException { 86 return input.read(buf, ofs, len); 87 } 88 89 90 @Override 91 public int read(byte[] buf) throws IOException { 92 return input.read(buf); 93 } 94 95 96 @Override 97 public long skip(long count) throws IOException { 98 return input.skip(count); 99 } 100 101 102 108 public long position() throws IOException { 109 return input.position() - origin; 110 } 111 112 113 122 public void position(long p) throws IOException { 123 input.position(p + origin); 124 } 125 } 126 | Popular Tags |