Interface CodePointReader


public interface CodePointReader
Reads code points from an input stream using a charset.

Use create(InputStream, Charset) to obtain an implementation optimized for the stream's capabilities.

  • Method Summary

    Modifier and Type
    Method
    Description
    create(InputStream input, Charset charset)
    Creates a code point reader optimized for the given input stream.
    read(int count)
    Reads the specified number of code points from the stream.
  • Method Details

    • create

      static CodePointReader create(InputStream input, Charset charset)
      Creates a code point reader optimized for the given input stream.

      If the stream supports mark/reset, returns a buffered implementation that reads ahead and resets on over-read. Otherwise, returns a byte-by-byte implementation.

      Parameters:
      input - the input stream to read from
      charset - the charset to use for decoding
      Returns:
      a code point reader
    • read

      String read(int count) throws IOException
      Reads the specified number of code points from the stream.
      Parameters:
      count - the number of code points to read (must be non-negative)
      Returns:
      the string containing the code points, or empty string if count is 0
      Throws:
      EOFException - if end of stream reached before reading the required code points
      IOException - if an I/O error occurs
      IllegalArgumentException - if count is negative