/** * Return the current read position of the stream. * * @return The current position relative to the beginning of the stream. * This is not the position relative to the start of the file, since * the stream starting position may be other than the beginning. */ public long getPosition() { checkOpenRuntime(); return bufpos + pos - start; }
/** * Mark the current position for retracing. * * @param readlimit The limit for the distance the read position can move from * the mark position before the mark is reset. */ public synchronized void mark(int readlimit) { checkOpenRuntime(); marklimit = readlimit; markpos = pos; }
/** * Create a new stream from this stream, using the given * start offset and length. * * @param offset The offset relative to the start of this stream instance. * @param end The end offset of the substream. If -1, the end of the parent stream is used. * * @return A new SharedFileInputStream object sharing the same source * input file. */ public InputStream newStream(long offset, long end) { checkOpenRuntime(); if (offset < 0) { throw new IllegalArgumentException("Start position is less than 0"); } // the default end position is the datalen of the one we're spawning from. if (end == -1) { end = datalen; } // create a new one using the private constructor return new SharedFileInputStream(source, start + (int)offset, (int)(end - offset), bufsize); }