1 2 3 4 package net.nutch.io; 5 6 import java.io.*; 7 8 9 28 public class DataInputBuffer extends DataInputStream { 29 30 private static class Buffer extends ByteArrayInputStream { 31 public Buffer() { 32 super(new byte[] {}); 33 } 34 35 public void reset(byte[] input, int start, int length) { 36 this.buf = input; 37 this.count = start+length; 38 this.mark = start; 39 this.pos = start; 40 } 41 42 public int getPosition() { return pos; } 43 } 44 45 private Buffer buffer; 46 47 48 public DataInputBuffer() { 49 this(new Buffer()); 50 } 51 52 private DataInputBuffer(Buffer buffer) { 53 super(buffer); 54 this.buffer = buffer; 55 } 56 57 58 public void reset(byte[] input, int length) { 59 buffer.reset(input, 0, length); 60 } 61 62 63 public void reset(byte[] input, int start, int length) { 64 buffer.reset(input, start, length); 65 } 66 67 68 public int getPosition() { return buffer.getPosition(); } 69 70 } 71 | Popular Tags |