Package org.verapdf.io
Class InternalInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.verapdf.as.io.ASInputStream
-
- org.verapdf.io.SeekableInputStream
-
- org.verapdf.io.InternalInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class InternalInputStream extends SeekableInputStream
ASInputStream for reading data from file. It contains methods for file closing management.- Author:
- Timur Kamalov
-
-
Field Summary
-
Fields inherited from class org.verapdf.as.io.ASInputStream
isClosed, isSourceClosed, resourceUsers
-
-
Constructor Summary
Constructors Constructor Description InternalInputStream(File file)InternalInputStream(File file, boolean isTempFile)InternalInputStream(File file, int numOfFileUsers, boolean isTempFile)InternalInputStream(RandomAccessFile stream, long fromOffset, long size, IntReference numOfFileUsers, String filePath, boolean isTempFile)InternalInputStream(RandomAccessFile stream, long fromOffset, long size, IntReference numOfFileUsers, String filePath, boolean isTempFile, int bufferSize)InternalInputStream(String fileName)InternalInputStream(String fileName, int numOfFileUsers)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseResource()Closes stream resource.static InternalInputStreamcreateConcatenated(byte[] alreadyRead, InputStream stream)Constructor writes into temp file passed buffer, then passed stream.longgetOffset()Gets offset of current byte.ASInputStreamgetStream(long startOffset, long length)Gets substream of this stream that starts at given offset and has given length.longgetStreamLength()Gets total length of stream.intpeek()Gets next byte without reading it.intread()intread(byte[] buffer, int size)voidreset()voidseek(long offset)Goes to a particular byte in stream.intskip(int size)-
Methods inherited from class org.verapdf.io.SeekableInputStream
decrementResourceUsers, getSeekableStream, incrementResourceUsers, isEOF, readByte, seekFromCurrentPosition, seekFromEnd, unread, unread
-
Methods inherited from class org.verapdf.as.io.ASInputStream
close, createStreamFromStream
-
Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, skip, transferTo
-
-
-
-
Constructor Detail
-
InternalInputStream
public InternalInputStream(File file) throws IOException
- Throws:
IOException
-
InternalInputStream
public InternalInputStream(File file, boolean isTempFile) throws IOException
- Throws:
IOException
-
InternalInputStream
public InternalInputStream(File file, int numOfFileUsers, boolean isTempFile) throws IOException
- Throws:
IOException
-
InternalInputStream
public InternalInputStream(String fileName) throws IOException
- Throws:
IOException
-
InternalInputStream
public InternalInputStream(String fileName, int numOfFileUsers) throws IOException
- Throws:
IOException
-
InternalInputStream
public InternalInputStream(RandomAccessFile stream, long fromOffset, long size, IntReference numOfFileUsers, String filePath, boolean isTempFile) throws IOException
- Throws:
IOException
-
InternalInputStream
public InternalInputStream(RandomAccessFile stream, long fromOffset, long size, IntReference numOfFileUsers, String filePath, boolean isTempFile, int bufferSize) throws IOException
- Throws:
IOException
-
-
Method Detail
-
createConcatenated
public static InternalInputStream createConcatenated(byte[] alreadyRead, InputStream stream) throws IOException
Constructor writes into temp file passed buffer, then passed stream. After that, InternalInputStream from file is created.- Parameters:
alreadyRead- is byte array of data that was already read from the beginning of stream.stream- is data left in stream.- Throws:
IOException
-
read
public int read() throws IOException- Specified by:
readin classASInputStream- Throws:
IOException
-
read
public int read(byte[] buffer, int size) throws IOException- Specified by:
readin classASInputStream- Throws:
IOException
-
skip
public int skip(int size) throws IOException- Specified by:
skipin classASInputStream- Throws:
IOException
-
reset
public void reset() throws IOException- Specified by:
resetin classASInputStream- Throws:
IOException
-
seek
public void seek(long offset) throws IOExceptionDescription copied from class:SeekableInputStreamGoes to a particular byte in stream.- Specified by:
seekin classSeekableInputStream- Parameters:
offset- is offset of a byte to go to.- Throws:
IOException
-
peek
public int peek() throws IOExceptionDescription copied from class:SeekableInputStreamGets next byte without reading it.- Specified by:
peekin classSeekableInputStream- Returns:
- next byte.
- Throws:
IOException
-
getOffset
public long getOffset() throws IOExceptionDescription copied from class:SeekableInputStreamGets offset of current byte.- Specified by:
getOffsetin classSeekableInputStream- Returns:
- offset of byte to be read next.
- Throws:
IOException
-
getStream
public ASInputStream getStream(long startOffset, long length) throws IOException
Description copied from class:SeekableInputStreamGets substream of this stream that starts at given offset and has given length.- Specified by:
getStreamin classSeekableInputStream- Parameters:
startOffset- is starting offset of substream.length- is length of substream.- Throws:
IOException
-
closeResource
public void closeResource() throws IOExceptionDescription copied from class:ASInputStreamCloses stream resource. There is a difference between closing stream and closing it's resource. Several streams may have the same resource (e. g. the same file stream) and resource should be closed only after all streams using it are closed.- Specified by:
closeResourcein classASInputStream- Throws:
IOException
-
getStreamLength
public long getStreamLength() throws IOExceptionDescription copied from class:SeekableInputStreamGets total length of stream.- Specified by:
getStreamLengthin classSeekableInputStream- Returns:
- length of stream in bytes.
- Throws:
IOException
-
-