@Override public void position(long newPosition) throws IOException { final long position = readBytes; /** Note that this check will succeed also in the case of * an empty buffer and position == newPosition. This behaviour is * intentional, as it delays buffering to when it is actually * necessary and avoids useless class the underlying stream. */ if (newPosition <= position + avail && newPosition >= position - pos) { pos += newPosition - position; avail -= newPosition - position; readBytes = newPosition; return; } if (repositionableStream != null) repositionableStream.position(newPosition); else if (fileChannel != null) fileChannel.position(newPosition); else throw new UnsupportedOperationException("position() can only be called if the underlying byte stream implements the RepositionableStream interface or if the getChannel() method of the underlying byte stream exists and returns a FileChannel"); readBytes = newPosition; avail = pos = 0; }
@Override public long position() throws IOException { if (repositionableStream != null) return repositionableStream.position() + pos; else if (measurableStream != null) return measurableStream.position() + pos; else if (fileChannel != null) return fileChannel.position() + pos; else throw new UnsupportedOperationException("position() can only be called if the underlying byte stream implements the MeasurableStream or RepositionableStream interface or if the getChannel() method of the underlying byte stream exists and returns a FileChannel"); }
/** Repositions the stream. * * <p>Note that this method performs a {@link #flush()} before changing the underlying stream position. */ @Override public void position(final long newPosition) throws IOException { flush(); if (repositionableStream != null) repositionableStream.position(newPosition); else if (fileChannel != null) fileChannel.position(newPosition); else throw new UnsupportedOperationException("position() can only be called if the underlying byte stream implements the RepositionableStream interface or if the getChannel() method of the underlying byte stream exists and returns a FileChannel"); }
/** * Tests passed stream is gzip stream by reading in the HEAD. * Does reposition of stream when done. * @param rs An InputStream that is Repositionable. * @return True if compressed stream. * @throws IOException */ public static boolean testCompressedRepositionalStream( final RepositionableStream rs) throws IOException { boolean compressedARCFile = false; long p = rs.position(); try { compressedARCFile = testCompressedStream((InputStream)rs); } finally { rs.position(p); } return compressedARCFile; }
/** * Tests passed stream is gzip stream by reading in the HEAD. * Does reposition of stream when done. * @param rs An InputStream that is Repositionable. * @return True if compressed stream. * @throws IOException */ public static boolean testCompressedRepositionalStream( final RepositionableStream rs) throws IOException { boolean compressedARCFile = false; long p = rs.position(); try { compressedARCFile = testCompressedStream((InputStream)rs); } finally { rs.position(p); } return compressedARCFile; }
/** * Tests passed stream is gzip stream by reading in the HEAD. * Does reposition of stream when done. * @param rs An InputStream that is Repositionable. * @return True if compressed stream. * @throws IOException */ public static boolean testCompressedRepositionalStream( final RepositionableStream rs) throws IOException { boolean compressedARCFile = false; long p = rs.position(); try { compressedARCFile = testCompressedStream((InputStream)rs); } finally { rs.position(p); } return compressedARCFile; }
if (position >>> 3 != this.position) repositionableStream.position(this.position = position >>> 3);
if ( position >> 3 != this.position ) repositionableStream.position( this.position = position >> 3 );
if ( position >> 3 != this.position ) repositionableStream.position( this.position = position >> 3 );
repositionableStream.position( this.position = position >> 3 );
repositionableStream.position( this.position = position >> 3 );
repositionableStream.position(this.position = position >> 3);