Package htsjdk.samtools.seekablestream
Class SeekableFileStream
- java.lang.Object
-
- java.io.InputStream
-
- htsjdk.samtools.seekablestream.SeekableStream
-
- htsjdk.samtools.seekablestream.SeekableFileStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class SeekableFileStream extends SeekableStream
-
-
Field Summary
-
Fields inherited from class htsjdk.samtools.seekablestream.SeekableStream
mark
-
-
Constructor Summary
Constructors Constructor Description SeekableFileStream(File file)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
static void
closeAllInstances()
boolean
eof()
String
getSource()
long
length()
long
position()
int
read()
int
read(byte[] b)
int
read(byte[] buffer, int offset, int length)
void
seek(long position)
Seeks the stream to the provided position.long
skip(long n)
-
Methods inherited from class htsjdk.samtools.seekablestream.SeekableStream
available, mark, markSupported, readFully, reset
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
SeekableFileStream
public SeekableFileStream(File file) throws FileNotFoundException
- Throws:
FileNotFoundException
-
-
Method Detail
-
length
public long length()
- Specified by:
length
in classSeekableStream
- Returns:
- the length of the stream; 0 if not available or empty.
-
eof
public boolean eof() throws IOException
- Specified by:
eof
in classSeekableStream
- Returns:
true
if the stream is already consumed;false
otherwise.- Throws:
IOException
-
seek
public void seek(long position) throws IOException
Description copied from class:SeekableStream
Seeks the stream to the provided position.- Specified by:
seek
in classSeekableStream
- Throws:
IOException
-
position
public long position() throws IOException
- Specified by:
position
in classSeekableStream
- Returns:
- the current byte position of the stream.
- Throws:
IOException
-
skip
public long skip(long n) throws IOException
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
read
public int read(byte[] buffer, int offset, int length) throws IOException
- Specified by:
read
in classSeekableStream
- Throws:
IOException
-
read
public int read() throws IOException
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
public int read(byte[] b) throws IOException
- Overrides:
read
in classInputStream
- Throws:
IOException
-
getSource
public String getSource()
- Specified by:
getSource
in classSeekableStream
- Returns:
- String representation of source (e.g. URL, file path, etc.), or null if not available.
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classSeekableStream
- Throws:
IOException
-
closeAllInstances
public static void closeAllInstances()
-
-