|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--norsys.netica.Streamer
An I/O handle to a file (for reading, writing, etc).
Constructor Summary | |
Streamer(java.io.InputStream inStream,
Environ env)
Constructs a Norsys stream from a java.io.InputStream. |
|
Streamer(java.io.OutputStream outStream,
Environ env)
Constructs a Norsys stream from a java.io.OutputStream. |
|
Streamer(java.lang.String fileName)
Returns a Norsys stream for the file with name filename, for the current default Environ (see getDefaultEnviron). |
|
Streamer(java.lang.String fileName,
Environ env)
Returns a Norsys stream for the file with name filename. |
Method Summary | |
void |
close()
Releases the memory used by the this Streamer. |
void |
finalize()
See close. |
void |
flush()
For a Streamer constructed from a java.io.OutputStream (see Streamer(OutputStream)), this will transfer the current contents of the Streamer to the the java.io.OutputStream. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Streamer(java.lang.String fileName) throws NeticaException
filename
- Path to the file to attach to this stream.public Streamer(java.lang.String fileName, Environ env) throws NeticaException
This stream can then be passed as an argument to functions which read or write a file, to identify which file to read or write.
When finished with the norsys.netica.Streamer created, delete it with close.
filename may contain a path to indicate in which directory the file is located. It should be a string in the format normally understood by the operating system currently being used (see the examples below).
filename does not have to indicate a file which already exists.
Version:
close | Delete it when done | |
write | Saves a net to a file with name specified by the passed stream | |
Net(Streamer) | Reads a net from the file identified by the passed stream |
See write// // Examples for UNIX / Linux // Streamer file = new Streamer ("temp3"); Streamer file = new Streamer ("/local/project1/configure.bn.txt"); Streamer file = new Streamer ("../nets/Umbrella.dnet"); // // Examples for MS Windows // Streamer file = new Streamer ("temp3"); Streamer file = new Streamer ("C:local\\project1\\configur.txt"); Streamer file = new Streamer ("..\\nets\\Umbrella.dnt"); // // Examples for MacOS // Streamer file = new Streamer ("temp3"); Streamer file = new Streamer ("local:project1:configure.bn.txt"); Streamer file = new Streamer ("::nets:Umbrella.dnet");
filename
- Path to the file to attach to this stream.env
- public Streamer(java.io.InputStream inStream, Environ env) throws NeticaException
inStream
- Any java.io.InputStream.public Streamer(java.io.OutputStream outStream, Environ env) throws NeticaException
Note: The outStream is only guaranteed to be filled after calling flush or close. Hence, always call flush or close after you have finished writing to the stream.
Example:
ByteArrayOutputStream baos = new ByteArrayOutputStream(); Streamer stream = new Streamer( baos, net.getEnviron() ); net.write( stream ); stream.flush();
outStream
- Any java.io.OutputStream.Method Detail |
public void flush() throws NeticaException
Both the Streamer and the OutputStream remain open for potentially further flushes.
If called on any other kind of Streamer, does nothing.
Example:
See the example for Streamer(OutputStream).
public void finalize() throws NeticaException
If you override this method, be sure to call the base class method (super.finalize();).
finalize
in class java.lang.Object
public void close() throws NeticaException
If this Streamer was constructed with either Streamer(String, Environ) or Streamer(String) then the associated file will be closed before deleting.
On the other hand, if either Streamer(OutputStream) or Streamer(InputStream) was used, then the associated OutputStream or InputStream is in no way affected by the closing of this stream.
Version:
Streamer | Creates a new Streamer |
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |