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
-
Constructor Summary
ConstructorDescriptionCharSequenceInputStream
(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 TypeMethodDescriptionint
Gets a lower bound on the number of bytes remaining in the byte stream.builder()
Constructs a newCharSequenceInputStream.Builder
.void
close()
void
mark
(int readLimit) boolean
int
read()
int
read
(byte[] b) int
read
(byte[] array, int off, int len) void
reset()
long
skip
(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:
available
in 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
mark
- Overrides:
mark
in classInputStream
- Parameters:
readLimit
- max read limit (ignored).
-
markSupported
- Overrides:
markSupported
in classInputStream
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
reset
- Overrides:
reset
in classInputStream
- Throws:
IOException
-
skip
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
builder()
,CharSequenceInputStream.Builder
, andCharSequenceInputStream.Builder.get()