okio / okio / BufferedSource / readDecimalLong

readDecimalLong

(js, jvm, native) abstract fun readDecimalLong():Long

Reads a long from this source in signed decimal form (i.e., as a string in base 10 with optional leading ‘-‘). This will iterate until a non-digit character is found.

Buffer buffer = new Buffer()
    .writeUtf8("8675309 -123 00001");

assertEquals(8675309L, buffer.readDecimalLong());
assertEquals(' ', buffer.readByte());
assertEquals(-123L, buffer.readDecimalLong());
assertEquals(' ', buffer.readByte());
assertEquals(1L, buffer.readDecimalLong());

Exceptions

NumberFormatException - if the found digits do not fit into a long or a decimal number was not present.