public class ReaderInputStream
extends java.io.InputStream
For example, the following code shows two methods that perform essentially the same conversion, except one uses character converters that are part of the Java runtime, and the other uses character converters that are part of the Toolbox:
public static InputStream getJavaConversionStream(String data, String encoding) { byte[] b = data.getBytes(encoding); return new java.io.ByteArrayInputStream(b); } public static InputStream getToolboxConversionStream(String data, String encoding) { StringReader r = new StringReader(data); return new com.ibm.as400.access.ReaderInputStream(r, encoding); }
ConvTableReader
,
InputStreamReader
Constructor and Description |
---|
ReaderInputStream(java.io.Reader reader,
int ccsid)
Constructs a ReaderInputStream that will convert Unicode characters into bytes of the specified CCSID.
|
ReaderInputStream(java.io.Reader reader,
int ccsid,
BidiConversionProperties properties)
Constructs a ReaderInputStream that will convert Unicode characters into bytes of the specified CCSID and bi-directional string type.
|
ReaderInputStream(java.io.Reader reader,
int ccsid,
BidiConversionProperties properties,
int cacheSize)
Constructs a ReaderInputStream that will convert Unicode characters into bytes of the specified CCSID and bi-directional string type.
|
ReaderInputStream(java.io.Reader reader,
int ccsid,
int bidiStringType)
Constructs a ReaderInputStream that will convert Unicode characters into bytes of the specified CCSID and bi-directional string type.
|
ReaderInputStream(java.io.Reader reader,
int ccsid,
int bidiStringType,
int cacheSize)
Constructs a ReaderInputStream that will convert Unicode characters into bytes of the specified CCSID and bi-directional string type.
|
ReaderInputStream(java.io.Reader reader,
java.lang.String encoding)
Constructs a ReaderInputStream that will convert Unicode characters into bytes of the specified encoding.
|
Modifier and Type | Method and Description |
---|---|
int |
available()
Returns the number of bytes stored in this ReaderInputStream's internal cache.
|
void |
close()
Closes this ReaderInputStream and its underlying Reader.
|
int |
getBidiStringType()
Returns the bi-directional string type in use by this ReaderInputStream.
|
int |
getCacheSize()
Returns the maximum number of characters that may be stored in the internal buffer.
|
int |
getCcsid()
Returns the CCSID used by this ReaderInputStream.
|
java.lang.String |
getEncoding()
Returns the encoding used by this ReaderInputStream.
|
int |
read()
Reads a single byte.
|
int |
read(byte[] buffer)
Reads bytes into the specified array.
|
int |
read(byte[] buffer,
int offset,
int length)
Reads bytes into a portion of the specified array.
|
long |
skip(long length)
Skips the specified number of bytes.
|
public ReaderInputStream(java.io.Reader reader, java.lang.String encoding) throws java.io.UnsupportedEncodingException
reader
- The Reader from which to read characters.encoding
- The name of a supported Java character encoding.java.io.UnsupportedEncodingException
- If the specified character encoding is not supported.public ReaderInputStream(java.io.Reader reader, int ccsid) throws java.io.UnsupportedEncodingException
reader
- The Reader from which to read characters.ccsid
- The CCSID used to convert characters into bytes.java.io.UnsupportedEncodingException
- If the specified CCSID or its corresponding character encoding is not supported.public ReaderInputStream(java.io.Reader reader, int ccsid, int bidiStringType) throws java.io.UnsupportedEncodingException
reader
- The Reader from which to read characters.ccsid
- The CCSID used to convert characters into bytes.bidiStringType
- The bi-directional string type
.java.io.UnsupportedEncodingException
- If the specified CCSID or its corresponding character encoding is not supported.public ReaderInputStream(java.io.Reader reader, int ccsid, BidiConversionProperties properties) throws java.io.UnsupportedEncodingException
reader
- The Reader from which to read characters.ccsid
- The CCSID used to convert characters into bytes.properties
- The bidi conversion properties.java.io.UnsupportedEncodingException
- If the specified CCSID or its corresponding character encoding is not supported.public ReaderInputStream(java.io.Reader reader, int ccsid, int bidiStringType, int cacheSize) throws java.io.UnsupportedEncodingException
reader
- The Reader from which to read characters.ccsid
- The CCSID used to convert characters into bytes.bidiStringType
- The bi-directional string type
.cacheSize
- The number of characters to store in the internal buffer. The default is 1024. This number must be greater than zero.java.io.UnsupportedEncodingException
- If the specified CCSID or its corresponding character encoding is not supported.public ReaderInputStream(java.io.Reader reader, int ccsid, BidiConversionProperties properties, int cacheSize) throws java.io.UnsupportedEncodingException
reader
- The Reader from which to read characters.ccsid
- The CCSID used to convert characters into bytes.properties
- The bidi conversion properties.cacheSize
- The number of characters to store in the internal buffer. The default is 1024. This number must be greater than zero.java.io.UnsupportedEncodingException
- If the specified CCSID or its corresponding character encoding is not supported.public int available() throws java.io.IOException
available
in class java.io.InputStream
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.InputStream
java.io.IOException
- If an I/O exception occurs.public int getBidiStringType()
bi-directional string type
.public int getCacheSize()
public int getCcsid()
public java.lang.String getEncoding()
public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
- If an I/O exception occurs.public int read(byte[] buffer) throws java.io.IOException
read
in class java.io.InputStream
buffer
- The destination buffer.java.io.IOException
- If an I/O exception occurs.public int read(byte[] buffer, int offset, int length) throws java.io.IOException
read
in class java.io.InputStream
buffer
- The destination buffer.offset
- The offset into the buffer at which to begin storing data.length
- The maximum number of bytes to store.java.io.IOException
- If an I/O exception occurs.public long skip(long length) throws java.io.IOException
skip
in class java.io.InputStream
length
- The number of bytes to skip.java.io.IOException
- If an I/O exception occurs.