public class FileSourceFactory
extends java.lang.Object
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 and Description |
---|
FileSourceFactory() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getXMLRootElement(java.lang.String fileName) |
static FileSource |
sourceFor(java.lang.String fileName)
Create a file input for the given file name.
|
public static FileSource sourceFor(java.lang.String fileName) throws java.io.IOException
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.
fileName
- Name of the graph file.java.io.IOException
- If the file is not readable or accessible.public static java.lang.String getXMLRootElement(java.lang.String fileName) throws java.io.IOException
java.io.IOException