public class FileSourceFactory extends 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 String |
getXMLRootElement(String fileName) |
static FileSource |
sourceFor(String fileName)
Create a file input for the given file name.
|
public static FileSource sourceFor(String fileName) throws 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.IOException
- If the file is not readable or accessible.public static String getXMLRootElement(String fileName) throws IOException
IOException
Copyright © 2015. All rights reserved.