public final class FileHandles extends Object
Each KnowledgeBase
has a single unique FileHandles
instance.
KnowledgeBase.getFileHandles()
Modifier and Type | Field and Description |
---|---|
static Atom |
USER_INPUT_HANDLE
The handle of the "standard" input stream.
|
static Atom |
USER_OUTPUT_HANDLE
The handle of the "standard" output stream.
|
Constructor and Description |
---|
FileHandles() |
Modifier and Type | Method and Description |
---|---|
void |
close(Term handle)
Closes the stream represented by the specified
Term . |
Term |
getCurrentInputHandle()
Return the
Term representing the current input stream. |
InputStream |
getCurrentInputStream()
Return the current input stream.
|
Term |
getCurrentOutputHandle()
Return the
Term representing the current output stream. |
PrintStream |
getCurrentOutputStream()
Return the current output stream.
|
boolean |
isHandle(String handle) |
Atom |
openInput(String fileName)
Creates an intput file stream to read from the file with the specified name
|
Atom |
openOutput(String fileName)
Creates an output file stream to write to the file with the specified name
|
void |
setInput(Term handle)
Sets the current input stream to the input stream represented by the specified
Term . |
void |
setOutput(Term handle)
Sets the current output stream to the output stream represented by the specified
Term . |
void |
setUserInput(InputStream is)
Reassigns the "standard" input stream.
|
void |
setUserOutput(PrintStream ps)
Reassigns the "standard" output stream.
|
public static final Atom USER_OUTPUT_HANDLE
By default the "standard" output stream will be System.out
.
public static final Atom USER_INPUT_HANDLE
By default the "standard" input stream will be System.in
.
public Term getCurrentInputHandle()
Term
representing the current input stream.
By default this will be an Atom
with the name "user_input
".
public Term getCurrentOutputHandle()
Term
representing the current output stream.
By default this will be an Atom
with the name "user_output
".
public InputStream getCurrentInputStream()
By default this will be System.in
.
public PrintStream getCurrentOutputStream()
By default this will be System.out
.
public void setUserInput(InputStream is)
USER_INPUT_HANDLE
public void setUserOutput(PrintStream ps)
USER_OUTPUT_HANDLE
public void setInput(Term handle)
Term
.ProjogException
- if the specified Term
does not represent an Atom
public void setOutput(Term handle)
Term
.ProjogException
- if the specified Term
does not represent an Atom
public Atom openInput(String fileName) throws IOException
fileName
- the system-dependent filenamesetInput(Term)
and close(Term)
)ProjogException
- if this object's collection of input streams already includes the specified fileIOException
- if the file cannot be opened for readingpublic Atom openOutput(String fileName) throws IOException
fileName
- the system-dependent filenamesetOutput(Term)
and close(Term)
)ProjogException
- if this object's collection of output streams already includes the specified fileIOException
- if the file cannot be openedpublic void close(Term handle) throws IOException
Term
.ProjogException
- if the specified Term
does not represent an Atom
IOException
- if an I/O error occurspublic boolean isHandle(String handle)
Copyright © 2024. All rights reserved.