isreadonly
isreadonly(stream) -> Bool
Determine whether a stream is read-only.
Examples
-
Check if a file stream is read-only:
julia> file = open("data.txt", "r"); julia> isreadonly(file) true
This example checks if the file stream
file
is read-only. -
Check if a writeable stream is read-only:
julia> writeable_stream = open("output.txt", "w"); julia> isreadonly(writeable_stream) false
It returns
false
since thewriteable_stream
is not read-only. - Check if a custom stream is read-only:
julia> struct MyStream read_only::Bool end julia> stream = MyStream(true); julia> isreadonly(stream) true
This example demonstrates how to use
isreadonly
with a custom stream object.
Common mistake example:
julia> isreadonly(5)
ERROR: MethodError: no method matching isreadonly(::Int64)
In this example, isreadonly
is called with an argument of type Int64
which is not a stream. Ensure that the argument passed to isreadonly
is a valid stream object to avoid such errors.
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.