public class RandomFileInputStream extends InputStream
| Modifier and Type | Field and Description |
|---|---|
protected RandomAccessFile |
randomFile |
| Constructor and Description |
|---|
RandomFileInputStream(File file)
Constructor.
|
RandomFileInputStream(RandomAccessFile randomFile)
Constructor.
|
RandomFileInputStream(String fileName)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the file.
|
long |
getLength()
Return the length (in bytes) of the file
|
void |
mark(int arg0) |
boolean |
markSupported()
Is file marking supported.
|
int |
read()
Read a byte value.
|
int |
read(byte[] buffer)
Read bytes into an array.
|
int |
read(byte[] buffer,
int pos,
int bytes)
Read bytes into an array.
|
void |
reset() |
void |
seek(long pos)
Seek to a position in the file.
|
long |
skip(long bytes)
Skip bytes in the input file.
|
availableprotected RandomAccessFile randomFile
public RandomFileInputStream(File file) throws FileNotFoundException
file - The File to readFileNotFoundException - If file is not foundpublic RandomFileInputStream(String fileName) throws FileNotFoundException
fileName - The name of the file to readFileNotFoundException - If the file is not found.public RandomFileInputStream(RandomAccessFile randomFile)
randomFile - The file to readpublic int read()
throws IOException
read in class InputStreamIOException - on IO errorInputStream.read()public void reset()
reset in class InputStreamInputStream.reset()public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class InputStreamIOException - on IO errorInputStream.close()public boolean markSupported()
markSupported in class InputStreamInputStream.markSupported()public void mark(int arg0)
mark in class InputStreamInputStream.mark(int)public long skip(long bytes)
throws IOException
skip in class InputStreambytes - The number of bytes to skipIOException - on IO errorInputStream.skip(long)public int read(byte[] buffer)
throws IOException
read in class InputStreambuffer - The buffer to read bytes intoIOException - on IO errorInputStream.read(byte[])public int read(byte[] buffer,
int pos,
int bytes)
throws IOException
read in class InputStreambuffer - The buffer to read bytes intopos - The start position in the bufferbytes - The number of bytes to readIOException - on IO errorInputStream.read(byte[], int, int)public void seek(long pos)
throws IOException
pos - The seek positionIOException - On error seekingpublic long getLength()
throws IOException
IOException - On file errorCopyright © 2004–2017. All rights reserved.