hashcode-utils-kt / org.hildan.hashcode.utils.reader / HCReader

HCReader

class HCReader : Closeable

Provides convenience methods to parse the input data, with clear error handling and line numbering.

Parameters

reader - the reader to use to read the input

tokenDelimiter - the delimiter to use to separate tokens

Constructors

<init>

Provides convenience methods to parse the input data, with clear error handling and line numbering.

HCReader(reader: Reader, tokenDelimiter: Regex = DEFAULT_HASHCODE_INPUT_DELIMITER)

Properties

lineNumber

The current line number. The value is 0 while nothing has been read yet, because the reader's position is considered to be before line 1.

val lineNumber: Int

Functions

close

Releases potential resources used by the reader. Should be called when parsing is over.

fun close(): Unit

nextLineText

Reads and returns the whole next line of input.

fun nextLineText(): String

nextLineTokens

Reads and returns the next line of input as a list of strings.

fun nextLineTokens(): List<String>

readBoolean

Reads the next token of the input as a boolean.

fun readBoolean(): Boolean

readDouble

Reads the next token of the input as a double.

fun readDouble(): Double

readInt

Reads the next token of the input as an int.

fun readInt(): Int

readString

Reads the next token of the input as a string.

fun readString(): String

skip

Skips the next n tokens of input.

fun skip(n: Int = 1): Unit