checkHeader

fun checkHeader(in: DataInput, codec: String?, minVersion: Int, maxVersion: Int): Int

Reads and validates a header previously written with .writeHeader.

When reading a file, supply the expected codec and an expected version range ( minVersion to maxVersion).

Return

The actual version found, when a valid header is found that matches codec, with an actual version where minVersion <= actual <= maxVersion. Otherwise an exception is thrown.

Parameters

in

Input stream, positioned at the point where the header was previously written. Typically this is located at the beginning of the file.

codec

The expected codec name.

minVersion

The minimum supported expected version number.

maxVersion

The maximum supported expected version number.

See also

.writeHeader

Throws

If the first four bytes are not .CODEC_MAGIC, or if the actual codec found is not codec.

If the actual version is less than minVersion.

If the actual version is greater than maxVersion * .

IOException

If there is an I/O error reading from the underlying medium.