Get a {@link ProvFormat} given the file's exetension
@param filename the file for which the {@link ProvFormat} is sought
@return a {@link ProvFormat}
324681
public ProvFormat getTypeForFile(String filename) {
        int count = filename.lastIndexOf(".");
        if (count == -1)
            return null;
        String extension = filename.substring(count + 1);
        return extensionRevMap.get(extension);
    }
290432
public static String getSafeFilename(String filename)
   {
      String result = filename;
      if (result != null)
      {
         result = result.replaceAll("[^a-zA-Z0-9]+", "-").replaceAll("^-+", "");
      }
      return result;
   }
1162888
private String getFileFromCache(String filename) {
        LRUCache.CacheEntry<String, T> cachedTemplate = cache.get(filename);

        if (cachedTemplate == null) {
            return null;
        }

        return cache.get(filename).raw;
    }
516968
public static String getFormatVersion(File filename) {
		final ContentFileTypeMap map = ensureContentTypeManager();
		return map.getFormatVersion(filename);
	}
394532
public static String getExtension(String fileName) {
    int pos = fileName.lastIndexOf('.');
    if (pos < 0) {
      return "";
    }
    return fileName.substring(pos + 1);
  }
23812
public static String getExtension(String fileName) {
        if (fileName == null)
            return null;

        String[] tokens = split(fileName);
        if (tokens.length >= 2)
            return tokens[tokens.length - 1];

        return null;
    }
1267287
public static Image getInstance(String filename)
			throws BadElementException, MalformedURLException, IOException {
		return getInstance(Utilities.toURL(filename));
	}
173235
public static String getExtension(String fileName) {
        if (fileName == null)
            return null;
        if (fileName.isEmpty())
            return "";

        int idx = fileName.lastIndexOf(".");
        if (idx != -1) {
            return fileName.substring(idx);
        } else {
            return "";
        }
    }
635202
@Nullable
    public static String getFileExtension(@NotNull String fileName) {
        @Nullable
        final String fileExt = FilenameUtils.getExtension(fileName);
        return StringUtils.isNoneEmpty(fileExt) ? StringUtils.lowerCase(fileExt) : null;
    }
31553
public static File getClasspathFile(String filename) {
    if(filename == null) {
      throw LOG.nullParameter("filename");
    }

    return getClasspathFile(filename, null);
  }
621880
protected function ftok($filename = "", $proj = "")
  {
    if (!function_exists('ftok')) {
      if (empty($filename) || !file_exists($filename)) {
        return -1;
      } else {
        $filename = $filename . (string) $proj;
        for($key = array(); sizeof($key) < strlen($filename); $key[] = ord(substr($filename, sizeof($key), 1)));
        return dechex(array_sum($key));
      }
    } else {
      return ftok($filename, $proj);
    }
  }
813520
public static String getContentType(final String fileName) {

		if (Util.empty(fileName)) {
			return ConfigurationProperties.getDefaultMimeType();
		}

		String mimeType = null;

		if (fileName.lastIndexOf('.') > -1) {
			String suffix = fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase();
			mimeType = ConfigurationProperties.getFileMimeTypeForExtension(suffix);
		}

		if (mimeType == null) {
			mimeType = URLConnection.guessContentTypeFromName(fileName);
			if (mimeType == null) {
				mimeType = ConfigurationProperties.getDefaultMimeType();
			}
		}

		return mimeType;
	}
104596
public static Dataset<String, String> readSVMLightFormat(String filename) {
    return readSVMLightFormat(filename, new HashIndex<String>(), new HashIndex<String>());
  }
200216
public static File toFile(final String filename) {
        if (filename == null) {
            return null;
        }
        String f;
        try {
            f = URLDecoder.decode(filename, UTF8);
        } catch (final UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        f = f.replace(WINDOWS_SEPARATOR, File.separator).replace(UNIX_SEPARATOR, File.separator);
        return new File(f);
    }
600462
public static String[] splitFileNameIntoPreSuffix(String fileName) {
        String[] preSuffix = {fileName, EMPTY};
        int dotIndex = fileName.lastIndexOf(DOT);
        if (dotIndex > 0) {
            preSuffix[0] = fileName.substring(0, dotIndex);
            preSuffix[1] = fileName.substring(dotIndex);
        }
        return preSuffix;
    }
833721
public static String guessFormat(String name) {
    String ext = FileUtil.getFilenameExtension(name);
    for(String format : FORMATS) {
      if(format.equalsIgnoreCase(ext)) {
        return ext;
      }
    }
    return null;
  }
618540
public void writeDocument(String filename, ProvFormat format, Document document) {
        Namespace.withThreadNamespace(document.getNamespace());
        try {
            logger.debug("writing " + format);
            logger.debug("writing " + filename);
            setNamespaces(document);
            switch (format) {
            case PROVN: {
                u.writeDocument(document, filename, pFactory);
                break;
            }
            case XML: {
                ProvSerialiser serial = ProvSerialiser
                        .getThreadProvSerialiser();
                logger.debug("namespaces " + document.getNamespace());
                serial.serialiseDocument(new File(filename), document, true);
                break;
            }
            case TURTLE: {
                new org.openprovenance.prov.rdf.Utility(pFactory, onto)
                        .dumpRDF(document, RDFFormat.TURTLE, filename);
                break;
            }
            case RDFXML: {
                new org.openprovenance.prov.rdf.Utility(pFactory, onto)
                        .dumpRDF(document, RDFFormat.RDFXML, filename);
                break;
            }
            case TRIG: {
                new org.openprovenance.prov.rdf.Utility(pFactory, onto)
                        .dumpRDF(document, RDFFormat.TRIG, filename);
                break;
            }
            case JSON: {
                new org.openprovenance.prov.json.Converter(pFactory)
                        .writeDocument(document, filename);
                break;
            }
            case DOT: {
                String configFile = null; // TODO: get it as option
                ProvToDot toDot = (configFile == null) ? new ProvToDot(
                        ProvToDot.Config.ROLE_NO_LABEL) : new ProvToDot(
                        configFile);
                toDot.setLayout(layout);
                toDot.convert(document, filename, title);
                break;
            }
            case PDF:
            case JPEG:
            case PNG:
            case SVG: {
                String configFile = null; // give it as option
                File tmp = File.createTempFile("viz-", ".dot");

                String dotFileOut = tmp.getAbsolutePath(); // give it as option,
                                                           // if not available
                                                           // create tmp file
                ProvToDot toDot;
                if (configFile != null) {
                    toDot = new ProvToDot(configFile);
                } else {
                    toDot = new ProvToDot(ProvToDot.Config.ROLE_NO_LABEL);
                }
                toDot.setLayout(layout);
                toDot.convert(document, dotFileOut, filename, extensionMap.get(format), title);
                tmp.delete();
                break;
            }

            default:
                break;
            }
        } catch (JAXBException e) {
            if (verbose != null)
                e.printStackTrace();
            throw new InteropException(e);

        } catch (IOException e) {
            if (verbose != null)
                e.printStackTrace();
            throw new InteropException(e);
        }

    }