Package org.apache.commons.io.input
Class CharSequenceInputStream
java.lang.Object
java.io.InputStream
org.apache.commons.io.input.CharSequenceInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
InputStream implementation that can read from String, StringBuffer,
StringBuilder or CharBuffer.
- Since:
- 2.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ByteBufferprivate static final intprivate final CharBufferprivate final CharsetEncoderprivate intprivate intprivate static final int -
Constructor Summary
ConstructorsConstructorDescriptionCharSequenceInputStream(CharSequence cs, String charset) Constructor, callsCharSequenceInputStream(CharSequence, String, int)with a buffer size of 2048.CharSequenceInputStream(CharSequence cs, String charset, int bufferSize) Constructor, callsCharSequenceInputStream(CharSequence, Charset, int).CharSequenceInputStream(CharSequence cs, Charset charset) Constructor, callsCharSequenceInputStream(CharSequence, Charset, int)with a buffer size of 2048.CharSequenceInputStream(CharSequence cs, Charset charset, int bufferSize) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionintReturn an estimate of the number of bytes remaining in the byte stream.voidclose()private voidFills the byte output buffer from the input char buffer.voidmark(int readlimit) booleanintread()intread(byte[] b) intread(byte[] array, int off, int len) voidreset()longskip(long n) Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
BUFFER_SIZE
private static final int BUFFER_SIZE- See Also:
-
NO_MARK
private static final int NO_MARK- See Also:
-
encoder
-
cbuf
-
bbuf
-
mark_cbuf
private int mark_cbuf -
mark_bbuf
private int mark_bbuf
-
-
Constructor Details
-
CharSequenceInputStream
Constructor.- Parameters:
cs- the input character sequencecharset- the character set name to usebufferSize- the buffer size to use.- Throws:
IllegalArgumentException- if the buffer is not large enough to hold a complete character
-
CharSequenceInputStream
Constructor, callsCharSequenceInputStream(CharSequence, Charset, int).- Parameters:
cs- the input character sequencecharset- the character set name to usebufferSize- the buffer size to use.- Throws:
IllegalArgumentException- if the buffer is not large enough to hold a complete character
-
CharSequenceInputStream
Constructor, callsCharSequenceInputStream(CharSequence, Charset, int)with a buffer size of 2048.- Parameters:
cs- the input character sequencecharset- the character set name to use- Throws:
IllegalArgumentException- if the buffer is not large enough to hold a complete character
-
CharSequenceInputStream
Constructor, callsCharSequenceInputStream(CharSequence, String, int)with a buffer size of 2048.- Parameters:
cs- the input character sequencecharset- the character set name to use- Throws:
IllegalArgumentException- if the buffer is not large enough to hold a complete character
-
-
Method Details
-
fillBuffer
Fills the byte output buffer from the input char buffer.- Throws:
CharacterCodingException- an error encoding data
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classInputStream- Throws:
IOException
-
available
Return an estimate of the number of bytes remaining in the byte stream.- Overrides:
availablein classInputStream- Returns:
- the count of bytes that can be read without blocking (or returning EOF).
- Throws:
IOException- if an error occurs (probably not possible)
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
mark
public void mark(int readlimit) - Overrides:
markin classInputStream- Parameters:
readlimit- max read limit (ignored)
-
reset
- Overrides:
resetin classInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classInputStream
-