| opens a textstream with default or given options.
open(+SourceSink, +IoMode, -Stream)
open(+SourceSink, +IoMode, -Stream, +Options)
open/3 opens a source or sink for input or output depending on the I/O-Mode,
with default options. open/4 opens a source or sink for input or output,
depending on the I/O-Mode, with the given options.
IoMode can have the following values:
| read |
stream is opened for reading. |
| write |
stream is opened for writing. If the opened object (maybe a file) is
already existing, its content will be overwritten. |
Options must be a list of options, where the options are elements
of the following atoms:
| file |
open a file. For applets the file will be opened relative to
the path of the html-file, with declares the applet-definition. |
| url |
opens an object, which url-address is given by the first argument of
open/4. |
| socket |
retrieves the inputstream/outputstream of an opened socket. The socket
must be passed as first argument of open/4. |
| atom |
opens an character input stream, where the content of the stream is
given by the characters given by the first argument (must be an atom). |
| text |
opens a text stream |
| binary |
opens a binary stream |
| buffered |
the opened stream will be buffered |
| unbuffered |
the opened stream will not be buffered |
| encoding(Encoding) |
the stream will be opened with the specific Encoding.
This will overwrite the command line argument "-encoding Encoding".
|
| syntax(StrictOrClassic) |
the text stream will be opened with or without the Java
international character set mapping. This is relevant when reading
Prolog terms.
This will overwrite the command line argument "-syntax strict|classic".
|
| type(term) |
the stream will be opened as a binary term stream.
|
Arguments
SourceSink Source or sink
IoMode read, write or append
Stream non atomic ground term
Options list of options
Examples
?- open('hello(world).', read, S, [atom]), read(S, T), close(S).
S = '__com.ifcomputer.minerva.MinervaTokenizer_679'
T = hello(world)
:
open(File,read,In,[encoding('EUCJIS')])
:
Standard
These predicates are part of the ISO-Prolog Standard. The option list
is not compatible with the ISO-Prolog Standard.
See also
at_end_of_stream/0/1,
close/1/2,
current_error/1,
current_input/1,
current_output/1,
flush_output/0/1,
set_error/1,
set_input/1,
set_output/1.
|