skip

skip(s, offset)

Seek a stream relative to the current position.

Examples

In the Julia programming language, the skip function is used to seek a stream relative to the current position. It allows you to skip a specified number of bytes or characters from the current position in the stream. It returns the updated stream after skipping.

julia> io = IOBuffer("Hello, World!")
julia> skip(io, 7)
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=13, maxsize=Inf, ptr=8, mark=-1)

Here are some common examples of how to use the skip function:

  1. Skip a specific number of bytes in a file:

    julia> file = open("data.txt", "r")
    julia> skip(file, 10)

    This example skips 10 bytes from the current position in the file.

  2. Skip a specific number of characters in a string:

    julia> str = "Julia Programming"
    julia> skip(str, 6)

    It skips 6 characters from the current position in the string.

  3. Skip to the end of the stream:

    julia> io = IOBuffer("Hello, World!")
    julia> skip(io, eof)

    This example skips to the end of the stream.

Common mistake example:

julia> io = IOBuffer("Hello, World!")
julia> skip(io, -5)
ERROR: InexactError: Int64(-5)

In this example, a negative offset is provided to the skip function. The offset should be a non-negative value. Make sure to provide a valid offset to avoid errors while using the skip function.

See Also

deserialize, eachline, eof, fd, flush, IOBuffer, ismarked, isopen, isreadonly, mark, nb_available, open, pipeline, position, read, read!, readavailable, readbytes, readbytes!, readline, redirect_stderr, redirect_stdin, reset, seek, seekend, seekstart, serialize, skip, skipchars, TextDisplay, unmark, write, writemime,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: