@PublicAPI public class PositionedInputStream extends java.io.BufferedInputStream
Modifier and Type | Field and Description |
---|---|
protected chemaxon.marvin.io.Encoding |
encoding
The encoding.
|
protected boolean |
keeporiginalLineEnding |
protected java.nio.ByteBuffer |
lineByteBuffer
Lines are read into this buffer.
|
protected int |
lineCurrentColumn
Column position of the next character to read.
|
Modifier | Constructor and Description |
---|---|
|
PositionedInputStream(java.io.InputStream is)
Constructor.
|
|
PositionedInputStream(java.io.InputStream is,
int size)
Constructor.
|
|
PositionedInputStream(java.io.InputStream is,
int size,
java.lang.String enc)
Constructor.
|
protected |
PositionedInputStream(java.io.InputStream is,
int size,
java.lang.String enc,
int initialChunkSize)
Constructor.
|
|
PositionedInputStream(java.io.InputStream is,
java.lang.String enc)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected int |
bufincRead()
Reads a character and writes into the buffer.
|
java.lang.String |
endGrabLines()
Ends grabbing lines.
|
chemaxon.marvin.io.Encoding |
getEncoding()
Gets the encoding.
|
long |
getFilePointer()
Get the file pointer.
|
java.lang.String |
getGrabbedLines()
Gets the grabbed lines.
|
java.lang.String |
getLastEOL() |
int |
getLineCount()
Gets the current line number.
|
protected int |
getWord(java.nio.ByteBuffer bb,
int i) |
boolean |
isSeekable()
Tests whether the stream is seekable.
|
long |
length()
Gets the file length.
|
void |
putBackLine()
Puts back the last line into the stream.
|
void |
putBackLine(int col)
Puts back the last line into the stream.
|
int |
read()
Reads a character.
|
int |
read(byte[] b,
int off,
int len)
Reads a byte array.
|
java.lang.String |
readLine()
Reads a line.
|
void |
reset()
Repositions this stream to the position at the time the
mark method was last called on this input stream. |
protected void |
resetFilePointer()
Resets file pointer to zero.
|
void |
seek(long p,
int lcount)
Sets the file-pointer offset, measured from the beginning of this
file, at which the next read or write occurs.
|
protected void |
setByteOrder(java.nio.ByteBuffer bb) |
void |
setDesiredBufferSize(int size)
Sets desired buffer size.
|
void |
setEncoding(chemaxon.marvin.io.Encoding enc)
Sets the encoding.
|
void |
setEncoding(java.lang.String enc)
Sets the encoding.
|
protected void |
setWord(java.nio.ByteBuffer bb,
int i,
int c) |
long |
skip(long n)
Skips over and discards n bytes of data.
|
boolean |
skipLine()
Skips the next line.
|
void |
startGrabLines()
Starts grabbing lines.
|
protected java.nio.ByteBuffer lineByteBuffer
readLine()
protected int lineCurrentColumn
protected boolean keeporiginalLineEnding
protected chemaxon.marvin.io.Encoding encoding
public PositionedInputStream(java.io.InputStream is) throws java.io.IOException
is
- the original input streamjava.io.IOException
public PositionedInputStream(java.io.InputStream is, int size) throws java.io.IOException
is
- the original input streamsize
- the buffer sizejava.io.IOException
public PositionedInputStream(java.io.InputStream is, java.lang.String enc) throws java.io.IOException
null
).is
- the original input streamenc
- the character encoding or null
java.io.IOException
public PositionedInputStream(java.io.InputStream is, int size, java.lang.String enc) throws java.io.IOException
null
).is
- the original input streamsize
- the buffer sizeenc
- the character encoding or null
java.io.IOException
protected PositionedInputStream(java.io.InputStream is, int size, java.lang.String enc, int initialChunkSize) throws java.io.IOException
is
- the original input streamsize
- the buffer sizeenc
- the character encoding or nullinitialChunkSize
- number of bytes to read in advance for
encoding recognitionjava.io.IOException
public void setDesiredBufferSize(int size)
size
- the desired buffer sizepublic int read() throws java.io.IOException
read
in class java.io.BufferedInputStream
java.io.IOException
- read error occurredprotected final int bufincRead() throws java.io.IOException
java.io.IOException
- in case of read errorpublic int read(byte[] b, int off, int len) throws java.io.IOException
read
in class java.io.BufferedInputStream
b
- the buffer into which the data is read.off
- the start offset of the datalen
- maximum number of bytes to readjava.io.IOException
- read error occurredpublic long skip(long n) throws java.io.IOException
skip
in class java.io.BufferedInputStream
n
- the number of bytesjava.io.IOException
- read error occurredpublic void reset() throws java.io.IOException
mark
method was last called on this input stream.reset
in class java.io.BufferedInputStream
java.io.IOException
- if this stream has not been marked or if the
mark has been invalidated.public final void startGrabLines()
endGrabLines()
,
getGrabbedLines()
public final java.lang.String endGrabLines()
public final java.lang.String getGrabbedLines()
public java.lang.String readLine() throws java.io.IOException
java.io.IOException
- If an I/O error has occurred.public boolean skipLine() throws java.io.IOException
true
if a line was skipped successfully,
false
at end of filejava.io.IOException
- If an I/O error has occurred.protected int getWord(java.nio.ByteBuffer bb, int i)
protected void setWord(java.nio.ByteBuffer bb, int i, int c)
public final int getLineCount()
public final void putBackLine() throws java.io.IOException
java.io.IOException
- If an I/O error has occurred.readLine()
,
getFilePointer()
public final void putBackLine(int col) throws java.io.IOException
col
- put back the substring starting at this columnjava.io.IOException
- If an I/O error has occurred.readLine()
,
getFilePointer()
protected final void resetFilePointer()
public final long getFilePointer()
public boolean isSeekable()
public void seek(long p, int lcount) throws java.io.IOException
p
- the offset positionlcount
- the line count at the specified positionjava.io.IOException
- if pos
is less than
0
or if an I/O error occurs.public long length() throws java.io.IOException
java.io.IOException
- if the file length cannot be determinedpublic final chemaxon.marvin.io.Encoding getEncoding()
public final void setEncoding(chemaxon.marvin.io.Encoding enc)
enc
- the encodingpublic final void setEncoding(java.lang.String enc)
enc
- the encodingjava.nio.charset.IllegalCharsetNameException
- if the encoding is illegaljava.nio.charset.UnsupportedCharsetException
- if the encoding is unsupportedprotected void setByteOrder(java.nio.ByteBuffer bb)
public java.lang.String getLastEOL()