Package org.jsoup.parser

## Class CharacterReader

- java.lang.Object
- - org.jsoup.parser.CharacterReader

    public final class CharacterReader
    extends java.lang.Object

CharacterReader consumes tokens off a string. Used internally by jsoup. API subject to changes.

### Constructor Summary

Constructors
`CharacterReader​(java.io.Reader input)`
`CharacterReader​(java.io.Reader input, int sz)`
`CharacterReader​(java.lang.String input)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `advance()` Moves the current position by one.
`void` `close()`
`java.lang.String` `consumeTo​(char c)` Reads characters up to the specific char.
`java.lang.String` `consumeToAny​(char... chars)` Read characters until the first of any delimiters is found.
`char` `current()` Get the char at the current position.
`boolean` `isEmpty()` Tests if all the content has been read.
`boolean` `isTrackNewlines()` Check if the tracking of newlines is enabled.
`int` `lineNumber()` Get the current line number (that the reader has consumed to).
`int` `pos()` Gets the current cursor position in the content.
`java.lang.String` `toString()`
`void` `trackNewlines​(boolean track)` Enables or disables line number tracking.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### CharacterReader

    public CharacterReader​(java.io.Reader input,
                           int sz)

#### CharacterReader

    public CharacterReader​(java.io.Reader input)

#### CharacterReader

    public CharacterReader​(java.lang.String input)

### Method Detail

#### close

    public void close()

#### pos

    public int pos()

Gets the current cursor position in the content.

Returns:
  current position

#### trackNewlines

    public void trackNewlines​(boolean track)

Enables or disables line number tracking. By default, will be off.Tracking line numbers improves the legibility of parser error messages, for example. Tracking should be enabled before any content is read to be of use.

Parameters:
  `track` - set tracking on|off
Since:
  1.14.3

#### isTrackNewlines

    public boolean isTrackNewlines()

Check if the tracking of newlines is enabled.

Returns:
  the current newline tracking state
Since:
  1.14.3

#### lineNumber

    public int lineNumber()

Get the current line number (that the reader has consumed to). Starts at line #1.

Returns:
  the current line number, or 1 if line tracking is not enabled.
Since:
  1.14.3
See Also:
  `trackNewlines(boolean)`

#### isEmpty

    public boolean isEmpty()

Tests if all the content has been read.

Returns:
  true if nothing left to read.

#### current

    public char current()

Get the char at the current position.

Returns:
  char

#### advance

    public void advance()

Moves the current position by one.

#### consumeTo

    public java.lang.String consumeTo​(char c)

Reads characters up to the specific char.

Parameters:
  `c` - the delimiter
Returns:
  the chars read

#### consumeToAny

    public java.lang.String consumeToAny​(char... chars)

Read characters until the first of any delimiters is found.

Parameters:
  `chars` - delimiters to scan for
Returns:
  characters read up to the matched delimiter.

#### toString

    public java.lang.String toString()

Overrides:
  `toString` in class `java.lang.Object`