@Test public void testSetPosition() throws Exception { Assert.assertEquals(data.length, stream.available()); Assert.assertEquals('0', stream.read()); stream.setPosition(1); Assert.assertEquals(data.length - 1, stream.available()); Assert.assertEquals('1', stream.read()); stream.setPosition(3); Assert.assertEquals(data.length - 3, stream.available()); Assert.assertEquals('3', stream.read()); stream.setPosition(data.length); Assert.assertEquals(0, stream.available()); Assert.assertEquals(-1, stream.read()); }
public void setPosition(int pos) { Preconditions.checkArgument(pos >= 0 && pos <= count, "Position out of bounds."); this.position = pos; }
ByteArrayInputStreamWithPos extends InputStream { public void setPosition(int pos) { Preconditions.checkArgument(pos >= 0 && pos <= count, "Position out of bounds."); this.position = pos; } }
ByteArrayInputStreamWithPos extends InputStream { public void setPosition(int pos) { Preconditions.checkArgument(pos >= 0 && pos <= count, "Position out of bounds."); this.position = pos; } ByteArrayInputStreamWithPos();  ByteArrayInputStreamWithPos(byte[] buffer);  ByteArrayInputStreamWithPos(byte[] buffer, int offset, int length); }
ByteArrayInputStreamWithPos extends InputStream { public void setPosition(int pos) { Preconditions.checkArgument(pos >= 0 && pos <= count, "Position out of bounds."); this.position = pos; } ByteArrayInputStreamWithPos();  ByteArrayInputStreamWithPos(byte[] buffer);  ByteArrayInputStreamWithPos(byte[] buffer, int offset, int length); @Override int read(); @Override int read(byte[] b, int off, int len); @Override long skip(long toSkip); @Override boolean markSupported(); @Override void mark(int readAheadLimit); @Override void reset(); @Override int available(); @Override void close(); int getPosition(); void setPosition(int pos); void setBuffer(byte[] buffer, int offset, int length); }
ByteArrayInputStreamWithPos extends InputStream { public void setPosition(int pos) { Preconditions.checkArgument(pos >= 0 && pos <= count, "Position out of bounds."); this.position = pos; } ByteArrayInputStreamWithPos();  ByteArrayInputStreamWithPos(byte[] buffer);  ByteArrayInputStreamWithPos(byte[] buffer, int offset, int length); @Override int read(); @Override int read(byte[] b, int off, int len); @Override long skip(long toSkip); @Override boolean markSupported(); @Override void mark(int readAheadLimit); @Override void reset(); @Override int available(); @Override void close(); int getPosition(); void setPosition(int pos); void setBuffer(byte[] buffer, int offset, int length);  }