No more data was available to read from a file or stream.


In Julia, the EOFError() function is used to indicate that there is no more data available to read from a file or stream. It is commonly used when reading input from a file or stream and reaching the end of the file.

Here is an example of its use:

julia> open("data.txt") do file
           while !eof(file)
               line = readline(file)
               println("Read line: $line")
           println("Reached end of file.")

In this example, the open function is used to open the file "data.txt". The while loop continues reading lines from the file until the eof function returns true, indicating the end of the file is reached. When the end of the file is reached, the message "Reached end of file." is printed and the EOFError() is thrown to indicate that there is no more data available.

Note that EOFError() can be caught using a try-catch block if you want to handle it in a specific way.

It's important to note that EOFError() is typically used in conjunction with other file handling functions and is not meant to be called directly in user code.

See Also

ArgumentError, AssertionError, BoundsError, DivideError, DomainError, EOFError, error, ErrorException, InexactError, InitError, KeyError, LoadError, MethodError, OutOfMemoryError, OverflowError, ParseError, ReadOnlyMemoryError, showerror, StackOverflowError, SystemError, TypeError, UndefRefError, UndefVarError,

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

Checking you are not a robot: