Get the next character in the source string. @return The next character, or 0 if past the end of the source string.
()
| 132 | * @return The next character, or 0 if past the end of the source string. |
| 133 | */ |
| 134 | public char next() throws JSONException { |
| 135 | int c; |
| 136 | if (this.usePrevious) { |
| 137 | this.usePrevious = false; |
| 138 | c = this.previous; |
| 139 | } else { |
| 140 | try { |
| 141 | c = this.reader.read(); |
| 142 | } catch (IOException exception) { |
| 143 | throw new JSONException(exception); |
| 144 | } |
| 145 | |
| 146 | if (c <= 0) { // End of stream |
| 147 | this.eof = true; |
| 148 | c = 0; |
| 149 | } |
| 150 | } |
| 151 | this.index += 1; |
| 152 | if (this.previous == '\r') { |
| 153 | this.line += 1; |
| 154 | this.character = c == '\n' ? 0 : 1; |
| 155 | } else if (c == '\n') { |
| 156 | this.line += 1; |
| 157 | this.character = 0; |
| 158 | } else { |
| 159 | this.character += 1; |
| 160 | } |
| 161 | this.previous = (char) c; |
| 162 | return this.previous; |
| 163 | } |
| 164 | |
| 165 | /** |
| 166 | * Consume the next character, and check that it matches a specified |