1 package be
.nikiroo
.utils
.streams
;
3 import java
.io
.FileInputStream
;
4 import java
.io
.FilterInputStream
;
5 import java
.io
.IOException
;
6 import java
.nio
.channels
.FileChannel
;
9 * This is a markable (and thus reset-able) stream that you can create from a
14 public class MarkableFileInputStream
extends FilterInputStream
{
15 private FileChannel channel
;
16 private long mark
= 0;
19 * Create a new {@link MarkableFileInputStream} from this stream.
22 * the original {@link FileInputStream} to wrap
24 public MarkableFileInputStream(FileInputStream in
) {
26 channel
= in
.getChannel();
30 public boolean markSupported() {
35 public synchronized void mark(int readlimit
) {
37 mark
= channel
.position();
38 } catch (IOException ex
) {
45 public synchronized void reset() throws IOException
{
47 throw new IOException("mark position not valid");
49 channel
.position(mark
);