Code example for CharsetDecoder

Methods: maxCharsPerByte

0
	 
	public InputStreamReader(InputStream in, CharsetDecoder cd, int bufferSize) {
		this.cd = cd;
		this.rbc = Channels.newChannel(in);
		this.bb = ByteBuffer.allocate(bufferSize);
		this.cb = CharBuffer.allocate((int)(bufferSize * (double)cd.maxCharsPerByte()));
		this.cb.limit(0);
	} 
	 
	@Override 
	public void close() throws IOException {
		rbc.close();
		cd.reset();
	} 
 
	@Override 
	public int read(char[] cbuf, int off, int len) throws IOException {
		if ((off < 0) || (off > cbuf.length) || (len < 0) ||
            ((off + len) > cbuf.length) || ((off + len) < 0)) {
            throw new IndexOutOfBoundsException();