code: public Document readDocumentFromFile(String filename, ProvFormat format) {
  
          try {
              switch (format) {
              case DOT:
              case JPEG:
              case PNG:
              case SVG:
                  throw new UnsupportedOperationException(); // we don't load PROV
                                                             // from these
                                                             // formats
              case JSON: {
                  return new org.openprovenance.prov.json.Converter(pFactory)
                          .readDocument(filename);
              }
  
              case PROVN: {
                  Utility u = new Utility();
                  CommonTree tree = u.convertASNToTree(filename);
                  Object o = u.convertTreeToJavaBean(tree, pFactory);
                  Document doc = (Document) o;
                  // Namespace ns=Namespace.gatherNamespaces(doc);
                  // doc.setNamespace(ns);
                  return doc;
              }
              case RDFXML:
              case TRIG:
              case TURTLE: {
                  org.openprovenance.prov.rdf.Utility rdfU = new org.openprovenance.prov.rdf.Utility(
                          pFactory, onto);
                  Document doc = rdfU.parseRDF(filename);
                  return doc;
              }
              case XML: {
                  File in = new File(filename);
                  ProvDeserialiser deserial = ProvDeserialiser
                          .getThreadProvDeserialiser();
                  Document doc = deserial.deserialiseDocument(in);
                  return doc;
              }
              default: {
                  System.out.println("Unknown format " + filename);
                  throw new UnsupportedOperationException();
              }
              }
          } catch (IOException e) {
              throw new InteropException(e);
          } catch (RDFParseException e) {
              throw new InteropException(e);
          } catch (RDFHandlerException e) {
              throw new InteropException(e);
          } catch (JAXBException e) {
              throw new InteropException(e);
          } catch (RecognitionException e) {
              throw new InteropException(e);
          }
  
      }
docs: Reads a document from a file, using the format to decide which parser to read the file with.
  @param filename the file to read a document from
  @param format the format of the file
  @return a Document