/** * Reads characters into a portion of an array. * * @param aBuf Destination buffer * @param nOfs Offset at which to start writing characters * @param nLen Maximum number of characters to read * @return The number of characters read, or -1 if the end of the stream has been reached * @exception IOException If an I/O error occurs */ @Override @CheckForSigned public int read( @Nonnull final char[] aBuf, @Nonnegative final int nOfs, @Nonnegative final int nLen) throws IOException { _ensureOpen(); ValueEnforcer.isArrayOfsLen(aBuf, nOfs, nLen); if (nLen == 0) return 0; if (m_nNext >= m_nLength) return -1; final int nChars = Math.min(m_nLength - m_nNext, nLen); m_sStr.getChars(m_nNext, m_nNext + nChars, aBuf, nOfs); m_nNext += nChars; return nChars; }
/** * Write a portion of an array of characters. * * @param aBuf Array of characters * @param nOfs Offset from which to start writing characters * @param nLen Number of characters to write */ @Override public void write( @Nonnull final char[] aBuf, @Nonnegative final int nOfs, @Nonnegative final int nLen) { ValueEnforcer.isArrayOfsLen(aBuf, nOfs, nLen); if (nLen > 0) m_aSB.append(aBuf, nOfs, nLen); }