public interface FileSource extends Source
The file input interface is an input with specific methods that deals with files. File inputs are designed to handle graphs stored under the form of a textual or binary file either under the form of a file name or a Java input stream. If the file comes from an URL, convert the URL to an input stream.
The file package is designed under the idea that it provides graph inputs from files that store the graph under a given file format and encoding. The package provides decoders for all these formats.
Do not confuse the file package with the net package that can also read from URLs, but build graph not from encoded description of a graph, but from web services like Flickr or Amazon, or simply networks of web pages tied by web links. The graph construction task is entirely different.
Although not all graph format handle dynamic graphs, all file inputs must provide both the readAll() and begin()/nextEvents()/end() methods. The later must read one graph modification at a time.
Modifier and Type | Method and Description |
---|---|
void |
begin(java.io.InputStream stream)
Begin reading the file stopping as soon as possible.
|
void |
begin(java.io.Reader reader)
Begin reading the file stopping as soon as possible.
|
void |
begin(java.lang.String fileName)
Begin reading the file stopping as soon as possible.
|
void |
begin(java.net.URL url)
Begin reading the file stopping as soon as possible.
|
void |
end()
Finish the reading process (even if
nextEvents() or
nextStep() did not returned false). |
boolean |
nextEvents()
Try to process one graph event, or as few as possible, if more must be read
at once.
|
boolean |
nextStep()
Try to process all the events occurring during one time step.
|
void |
readAll(java.io.InputStream stream)
Read the whole file in one big non-interruptible operation.
|
void |
readAll(java.io.Reader reader)
Read the whole file in one big non-interruptible operation.
|
void |
readAll(java.lang.String fileName)
Read the whole file in one big non-interruptible operation.
|
void |
readAll(java.net.URL url)
Read the whole file in one big non-interruptible operation.
|
addAttributeSink, addElementSink, addSink, clearAttributeSinks, clearElementSinks, clearSinks, removeAttributeSink, removeElementSink, removeSink
void readAll(java.lang.String fileName) throws java.io.IOException
fileName
- Name of the file to read.java.io.IOException
- If an I/O error occurs while reading.void readAll(java.net.URL url) throws java.io.IOException
url
- The URL of the file to read.java.io.IOException
- If an I/O error occurs while reading.void readAll(java.io.InputStream stream) throws java.io.IOException
stream
- The input stream to use for reading.java.io.IOException
- If an I/O error occurs while reading.void readAll(java.io.Reader reader) throws java.io.IOException
reader
- The reader to use.java.io.IOException
- If an I/O error occurs while reading.void begin(java.lang.String fileName) throws java.io.IOException
nextEvents()
or
nextStep()
. Once begin() has been called, you must finish the
reading process using end()
. You cannot call begin() twice without
having called end()
in between.fileName
- Name of the file to read.java.io.IOException
- If an I/O error occurs while reading.void begin(java.net.URL url) throws java.io.IOException
nextEvents()
or
nextStep()
. Once begin() has been called, you must finish the
reading process using end()
. You cannot call begin() twice without
having called end()
in between.url
- The URL of the file to read.java.io.IOException
- If an I/O error occurs while reading.void begin(java.io.InputStream stream) throws java.io.IOException
nextEvents()
or
nextStep()
. Once begin() has been called, you must finish the
reading process using end()
. You cannot call begin() twice without
having called end()
in between.stream
- The input stream to use for reading.java.io.IOException
- If an I/O error occurs while reading.void begin(java.io.Reader reader) throws java.io.IOException
nextEvents()
or
nextStep()
. Once begin() has been called, you must finish the
reading process using end()
. You cannot call begin() twice without
having called end()
in between.reader
- The file reader to use.java.io.IOException
- If an I/O error occurs while reading.boolean nextEvents() throws java.io.IOException
begin(InputStream)
or begin(String)
before. This method
return true while there are still events to read.java.io.IOException
- If an I/O error occurs while reading.boolean nextStep() throws java.io.IOException
java.io.IOException
- If an I/O error occurs while reading.void end() throws java.io.IOException
nextEvents()
or
nextStep()
did not returned false). You must call this method after
reading.java.io.IOException
- If an I/O error occurs while closing the file.