Class PlaybackInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
If the encoding is changed, then the scanner calls the playback
method and re-scans the beginning of the HTML document again. This should not
be too much of a performance problem because the <meta> tag appears at
the beginning of the document.
If the <body> tag is reached without playing back the bytes, then the
buffer can be cleared by calling the clear
method. This stops
the buffering of bytes and allows the memory used by the buffer to be
reclaimed.
Note: If the buffer is never played back or cleared, this input stream will continue to buffer the entire stream. Therefore, it is very important to use this stream correctly.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]
Byte buffer.private int
Length of bytes read into byte buffer.private int
Offset into byte buffer during playback.private boolean
Buffer cleared.private static final boolean
Set to true to debug playback.private boolean
Encoding detected.private final InputStream
Our inputstreamprivate boolean
Playback mode.private int
Pushback length.private int
Pushback offset. -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Field Details
-
DEBUG_PLAYBACK
private static final boolean DEBUG_PLAYBACKSet to true to debug playback.- See Also:
-
playback_
private boolean playback_Playback mode. -
cleared_
private boolean cleared_Buffer cleared. -
detected_
private boolean detected_Encoding detected. -
byteBuffer_
private byte[] byteBuffer_Byte buffer. -
byteOffset_
private int byteOffset_Offset into byte buffer during playback. -
byteLength_
private int byteLength_Length of bytes read into byte buffer. -
pushbackOffset_
private int pushbackOffset_Pushback offset. -
pushbackLength_
private int pushbackLength_Pushback length. -
in_
Our inputstream
-
-
Constructor Details
-
PlaybackInputStream
-
-
Method Details
-
detectEncoding
- Throws:
IOException
-
playback
public void playback()Playback buffer contents. -
clear
public void clear()Clears the buffer.Note: The buffer cannot be cleared during playback. Therefore, calling this method during playback will not do anything. However, the buffer will be cleared automatically at the end of playback.
-
read
Read a byte.- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
Read an array of bytes.- Overrides:
read
in classInputStream
- Throws:
IOException
-
read
Read an array of bytes.- Overrides:
read
in classInputStream
- Throws:
IOException
-