Basic input and output
Julia's vision on input/output (I/O) is stream-oriented, that is, reading or writing streams of bytes. We will introduce different types of stream, file streams, in this chapter. Standard input (stdin) and standard output (stdout) are constants of the TTY
 type (an abbreviation for the old term, Teletype
) that can be read from and written to in Julia code (refer to the code in Chapter 8\io.jl
):
read(stdin, Char)
: This command waits for a character to be entered, and then returns that character; for example, when you type inJ
, this returns'J'
write(stdout, "Julia")
: This command types outJulia5
(the added5
is the number of bytes in the output stream; it is not added if the command ends in a semicolon;
)
stdin
 and stdout
are simply streams and can be replaced by any stream object in read/write commands. readbytes
is used to read a number of bytes from a stream into a vector:
read(stdin,3)
: This command waits for an input, for example,abe
reads three bytes from it, and...