org.graphstream.stream.file
Class FileSourceFactory

java.lang.Object
  extended by org.graphstream.stream.file.FileSourceFactory

public class FileSourceFactory
extends Object

File source factory.

A graph reader factory allow to create readers according to a given file. It both tries to read the start of the file to infer its type (works well for file formats with a magic cookie or header), and if it fails it tries to look at the file name extension.


Constructor Summary
FileSourceFactory()
           
 
Method Summary
static FileSource sourceFor(String fileName)
          Create a file input for the given file name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSourceFactory

public FileSourceFactory()
Method Detail

sourceFor

public static FileSource sourceFor(String fileName)
                            throws IOException
Create a file input for the given file name.

This method first tests if the file is a regular file and is readable. If so, it opens it and reads the magic cookie to test the known file formats that can be inferred from their header. If it works, it returns a file input for the format. Else it looks at the file name extension, and returns a file input for the extension. Finally if all fail, it throws a NotFoundException.

Notice that this method only creates the file input and does not connect it to a graph.

Parameters:
fileName - Name of the graph file.
Returns:
A graph reader suitable for the fileName graph format.
Throws:
IOException - If the file is not readable or accessible.


Copyright © 2011. All Rights Reserved.