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
Implements an
InputStream to read bytes from String, StringBuffer, StringBuilder or CharBuffer,
encoded using the specified Charset. The Charset defaults to Charset.defaultCharset().
Note: Supports mark(int) and reset().
To build an instance, use CharSequenceInputStream.Builder.
- Since:
- 2.2
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionCharSequenceInputStream(CharSequence cs, String charset) Deprecated.CharSequenceInputStream(CharSequence cs, String charset, int bufferSize) Deprecated.CharSequenceInputStream(CharSequence cs, Charset charset) Deprecated.CharSequenceInputStream(CharSequence cs, Charset charset, int bufferSize) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionintGets a lower bound on the number of bytes remaining in the byte stream.builder()Constructs a newCharSequenceInputStream.Builder.voidclose()voidmark(int readLimit) booleanintread()intread(byte[] b) intread(byte[] array, int off, int len) voidreset()longskip(long n)
-
Constructor Details
-
CharSequenceInputStream
Deprecated.Constructs a new instance with a buffer size ofIOUtils.DEFAULT_BUFFER_SIZE.- Parameters:
cs- the input character sequence.charset- the character set name to use.- Throws:
IllegalArgumentException- if the buffer is not large enough to hold a complete character.
-
CharSequenceInputStream
Deprecated.Constructs a new instance.- Parameters:
cs- the input character sequence.charset- the character set name to use, null maps to the default Charset.bufferSize- the buffer size to use.- Throws:
IllegalArgumentException- if the buffer is not large enough to hold a complete character.
-
CharSequenceInputStream
Deprecated.Constructs a new instance with a buffer size ofIOUtils.DEFAULT_BUFFER_SIZE.- Parameters:
cs- the input character sequence.charset- the character set name to use.- Throws:
IllegalArgumentException- if the buffer is not large enough to hold a complete character.
-
CharSequenceInputStream
Deprecated.Constructs a new instance.- Parameters:
cs- the input character sequence.charset- the character set name to use, null maps to the default Charset.bufferSize- the buffer size to use.- Throws:
IllegalArgumentException- if the buffer is not large enough to hold a complete character.
-
-
Method Details
-
builder
Constructs a newCharSequenceInputStream.Builder.- Returns:
- a new
CharSequenceInputStream.Builder. - Since:
- 2.12.0
-
available
Gets a lower bound on 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
- Overrides:
markin classInputStream- Parameters:
readLimit- max read limit (ignored).
-
markSupported
- Overrides:
markSupportedin classInputStream
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
reset
- Overrides:
resetin classInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classInputStream- Throws:
IOException
-
builder(),CharSequenceInputStream.Builder, andCharSequenceInputStream.Builder.get()