Experimental code, trying to load a document without knowing its serialization format.
First parser that succeeds returns a results. Not a robust method!
@param filename a file to load the provenance document from
@return a document
173000
public Object loadProvUnknownGraph(String filename) {

        try {
            Utility u = new Utility();
            CommonTree tree = u.convertASNToTree(filename);
            Object o = u.convertTreeToJavaBean(tree, pFactory);
            if (o != null) {
                return o;
            }
        } catch (RecognitionException t1) {
            // OK, we failed, let's try next format.
        } catch (IOException e) {
            // OK, we failed, let's try next format.
        }
        try {
            File in = new File(filename);
            ProvDeserialiser deserial = ProvDeserialiser
                    .getThreadProvDeserialiser();
            Document c = deserial.deserialiseDocument(in);
            if (c != null) {
                return c;
            }
        } catch (JAXBException t2) {
            // OK, we failed, let's try next format.
        }

        try {
            Document o = new org.openprovenance.prov.json.Converter(pFactory)
                    .readDocument(filename);
            if (o != null) {
                return o;
            }
        } catch (IOException e) {
            // OK, we failed, let's try next format.

        }
        try {
            org.openprovenance.prov.rdf.Utility rdfU = new org.openprovenance.prov.rdf.Utility(
                    pFactory, onto);
            Document doc = rdfU.parseRDF(filename);
            if (doc != null) {
                return doc;
            }
        } catch (RDFParseException e) {
        } catch (RDFHandlerException e) {
        } catch (IOException e) {
        } catch (JAXBException e) {
        }
        System.out.println("Unparseable format " + filename);
        throw new UnsupportedOperationException();

    }
546733
public function fromFile($filename)
    {
        $xml = $this->createDomDocument();
        $xml->load($filename);

        return new Document($xml);
    }
1285093
public static InputStream loadFile(String fileName) {
        logger.entering(fileName);
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        InputStream iStream = loader.getResourceAsStream(fileName);
        if (iStream == null) {
            try {
                iStream = new FileInputStream(fileName);
            } catch (FileNotFoundException e) { // NOSONAR
                // Gobbling the checked exception here and doing nothing with it
                // because we are explicitly checking if the inputstream is null
                // and then throwing a runtime exception
            }
        }
        if (iStream == null) {
            throw new IllegalArgumentException("[" + fileName + "] is not a valid resource");
        }
        logger.exiting();
        return iStream;
    }
1082940
private Document loadDocument(String file) {
		Document doc = null;
		URL url = null;
		File f = new File(file);
		if (f.exists()) {
			try {
				url = f.toURI().toURL();
			} catch (MalformedURLException e) {
				throw new ConfigurationException("Unable to load " + file, e);
			}
		}
		if (url == null) {
			url = ClassLoader.getSystemResource(file);
		}
		InputStream is = null;
		if (url == null) {
			if (errorIfMissing) {
				throw new ConfigurationException("Could not open files of the name " + file);
			} else {
				LOG.info("Unable to locate configuration files of the name " + file + ", skipping");
				return doc;
			}
		}
		try {
			is = url.openStream();
			InputSource in = new InputSource(is);
			in.setSystemId(url.toString());
			doc = DomHelper.parse(in, dtdMappings);
		} catch (Exception e) {
			throw new ConfigurationException("Unable to load " + file, e);
		} finally {
			try {
				is.close();
			} catch (IOException e) {
				LOG.error("Unable to close input stream", e);
			}
		}
		if (doc != null) {
			LOG.debug("Wallmod configuration parsed");
		}
		return doc;
	}
458674
@Override
    public void read(final File filename) {
        filePath = filename;

        //clear the history on global metadata table
        globalMeta.clear();
        super.read(filename);
    }
1170380
public T loadCSV( String fileName )
            throws IOException {
        DMatrix mat = MatrixIO.loadCSV(fileName,true);

        T ret = createMatrix(1,1, mat.getType());

        ret.setMatrix(mat);

        return ret;
    }
516968
public static String getFormatVersion(File filename) {
		final ContentFileTypeMap map = ensureContentTypeManager();
		return map.getFormatVersion(filename);
	}
582311
public static File toFile(final URI filename) {
        if (filename == null) {
            return null;
        }
        final URI f = stripFragment(filename);
        if ("file".equals(f.getScheme()) && f.getPath() != null && f.isAbsolute()) {
            return new File(f);
        } else {
            return toFile(f.toString());
        }
    }
258097
private static String readFile(final String fileName) throws IOException {
    return new String(Files.readAllBytes(Paths.get(fileName)), StandardCharsets.UTF_8);
  }
580941
public static OutputStream getOutputStreamFromFilename(String filename) {
        try {
            return new FileOutputStream(filename);
        } catch (FileNotFoundException e) {
            log.debug("Error initializing RdfStreamReader, file '{}' not found", filename);
            // do not handle exception at construction time
            return null;
        }
    }
1153396
public File getFile(String fileName) throws IOException {
    validatePathname(fileName);

    String pathname = storageDir + separator + fileName;

    File file = new File(pathname);
    if (!file.exists()) {
      throw new FileNotFoundException(pathname);
    }
    if (!file.isFile()) {
      throw new IOException('\'' + pathname + '\'' + " is not a file");
    }
    return file;
  }
1240494
public static String readFileContent(String filename) throws FileNotFoundException, IOException {
        BufferedReader reader = new BufferedReader(new FileReader(filename));
        StringBuilder content = new StringBuilder();
        String line;
        final String eol = System.getProperty("line.separator");
        while ((line = reader.readLine()) != null) {
            content.append(line);
            content.append(eol);
        }
        reader.close();
        return content.toString();
    }
428170
def loadFromFile(self, filename):
        
        if self.__base_url:
            filename = basejoin(self.__base_url,filename)
        file = open(filename, 'rb')
        try:
            schema = self.loadFromStream(file, filename)
        finally:
            file.close()

        return schema
636708
public static function load( $fileName )
	{
		$parser	= new XML_DOM_Parser();
		$xml	= FS_File_Reader::load( $fileName );
		$tree	= $parser->parse( $xml );
		return $tree;
	}
80307
public String read(final String filename) {
        if (isFresh(filename)) {
            String cachedValue = getFileFromCache(filename);
            if (cachedValue != null) {
                return cachedValue;
            }
        }
        // either fresh is false or cachedValue is null
        loadToCache(filename);
        return getFileFromCache(filename);
    }
971927
public InputStream loadTemplate(String fileName) throws IOException {
	Path currentPath=new Path(fileName);
	return openFile(currentPath);
}
511813
public JCTree.JCCompilationUnit parse(JavaFileObject filename) {
        JavaFileObject prev = log.useSource(filename);
        try {
            JCTree.JCCompilationUnit t = parse(filename, readSource(filename));
            if (t.endPositions != null)
                log.setEndPosTable(filename, t.endPositions);
            return t;
        } finally {
            log.useSource(prev);
        }
    }