Package jmri.util

Class FileUtilSupport

    • Constructor Summary

      Constructors 
      Constructor Description
      FileUtilSupport()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void appendTextToFile​(java.io.File file, java.lang.String text)
      Simple helper method to just append a text string to the end of the given filename.
      void backup​(java.io.File file)
      Backup a file.
      void copy​(java.io.File source, java.io.File dest)
      Copy a file or directory.
      void createDirectory​(java.io.File dir)
      Create a directory if required.
      void createDirectory​(java.lang.String path)
      Create a directory if required.
      boolean delete​(java.io.File path)
      Recursively delete a path.
      java.net.URL fileToURL​(java.io.File file)
      Return the URL for a given File.
      java.net.URI findExternalFilename​(java.lang.String path)
      Get the URL of a portable filename if it can be located using findURI(java.lang.String)
      java.util.Set<java.io.File> findFiles​(java.lang.String name, java.lang.String root)
      Find all files matching the given name under the given root directory within both the user and installed file locations.
      java.util.Set<java.io.File> findFiles​(java.lang.String name, java.lang.String root, FileUtil.Location location)
      Find all files matching the given name under the given root directory within the specified location.
      java.io.InputStream findInputStream​(java.lang.String path)
      Search for a file or JAR resource by name and return the InputStream for that file.
      java.io.InputStream findInputStream​(java.lang.String path, java.lang.String... searchPaths)
      Search for a file or JAR resource by name and return the InputStream for that file.
      java.io.InputStream findInputStream​(java.lang.String path, FileUtil.Location locations)
      Search for a file or JAR resource by name and return the InputStream for that file.
      java.io.InputStream findInputStream​(java.lang.String path, FileUtil.Location locations, java.lang.String... searchPaths)
      Search for a file or JAR resource by name and return the InputStream for that file.
      java.net.URI findURI​(java.lang.String path)
      Search for a file or JAR resource by name and return the URI for that file.
      java.net.URI findURI​(java.lang.String path, java.lang.String... searchPaths)
      Search for a file or JAR resource by name and return the URI for that file.
      java.net.URI findURI​(java.lang.String path, FileUtil.Location locations)
      Search for a file or JAR resource by name and return the URI for that file.
      java.net.URI findURI​(java.lang.String path, FileUtil.Location locations, java.lang.String... searchPaths)
      Search for a file or JAR resource by name and return the URI for that file.
      java.net.URL findURL​(java.lang.String path)
      Search for a file or JAR resource by name and return the URL for that file.
      java.net.URL findURL​(java.lang.String path, java.lang.String... searchPaths)
      Search for a file or JAR resource by name and return the URL for that file.
      java.net.URL findURL​(java.lang.String path, FileUtil.Location locations)
      Search for a file or JAR resource by name and return the URL for that file.
      java.net.URL findURL​(java.lang.String path, FileUtil.Location locations, java.lang.String... searchPaths)
      Search for a file or JAR resource by name and return the URL for that file.
      java.lang.String getAbsoluteFilename​(java.lang.String path)
      Convert a portable filename into an absolute filename, using ProfileManager.getActiveProfile() as the base.
      java.lang.String getAbsoluteFilename​(Profile profile, java.lang.String path)
      Convert a portable filename into an absolute filename.
      java.io.File getCacheDirectory()
      Get the JMRI cache location, ensuring its existence.
      static FileUtilSupport getDefault()
      Get the default instance of a FileUtilSupport object.
      java.lang.String getExternalFilename​(java.lang.String pName)
      Get the resource file corresponding to a name.
      java.lang.String getExternalFilename​(Profile profile, java.lang.String pName)
      Get the resource file corresponding to a name.
      java.io.File getFile​(java.lang.String path)
      Get the File that path refers to.
      java.io.File getFile​(Profile profile, java.lang.String path)
      Get the File that path refers to.
      java.lang.String getHomePath()
      Get the user's home directory.
      java.util.jar.JarFile getJmriJarFile()
      Get the JMRI distribution jar file.
      java.lang.String getPortableFilename​(java.io.File file)
      Convert a File object's path to our preferred storage form.
      java.lang.String getPortableFilename​(java.io.File file, boolean ignoreUserFilesPath, boolean ignoreProfilePath)
      Convert a File object's path to our preferred storage form.
      java.lang.String getPortableFilename​(java.lang.String filename)
      Convert a filename string to our preferred storage form.
      java.lang.String getPortableFilename​(java.lang.String filename, boolean ignoreUserFilesPath, boolean ignoreProfilePath)
      Convert a filename string to our preferred storage form.
      java.lang.String getPortableFilename​(Profile profile, java.io.File file)
      Convert a File object's path to our preferred storage form.
      java.lang.String getPortableFilename​(Profile profile, java.io.File file, boolean ignoreUserFilesPath, boolean ignoreProfilePath)
      Convert a File object's path to our preferred storage form.
      java.lang.String getPortableFilename​(Profile profile, java.lang.String filename)
      Convert a filename string to our preferred storage form.
      java.lang.String getPortableFilename​(Profile profile, java.lang.String filename, boolean ignoreUserFilesPath, boolean ignoreProfilePath)
      Convert a filename string to our preferred storage form.
      java.lang.String getPreferencesPath()
      Get the preferences directory.
      java.lang.String getProfilePath()
      Get the profile directory.
      java.lang.String getProfilePath​(Profile profile)
      Get the profile directory.
      java.lang.String getProgramPath()
      Get the JMRI program directory.
      java.lang.String getScriptsPath()
      Get the path to the scripts directory.
      java.lang.String getScriptsPath​(Profile profile)
      Get the path to the scripts directory.
      java.net.URI getURI​(java.lang.String path)
      Get the File that path refers to.
      java.net.URL getURL​(java.lang.String path)
      Get the URL that path refers to.
      java.net.URL getURL​(java.net.URI uri)
      Convenience method to get the URL from a URI.
      java.lang.String getUserFilesPath()
      Get the user's files directory.
      java.lang.String getUserFilesPath​(Profile profile)
      Get the user's files directory.
      java.lang.String getUserResourcePath()
      Get the resources directory within the user's files directory.
      boolean isPortableFilename​(java.lang.String filename)
      Test if the given filename is a portable filename.
      void logFilePaths()
      Log all paths at the INFO level.
      java.lang.String readFile​(java.io.File file)
      Read a text file into a String.
      java.lang.String readURL​(java.net.URL url)
      Read a text URL into a String.
      void rotate​(java.io.File file, int max, java.lang.String extension)
      Rotate a file and its backups, retaining only a set number of backups.
      java.lang.String sanitizeFilename​(java.lang.String name)
      Replaces most non-alphanumeric characters in name with an underscore.
      void setProgramPath​(java.io.File path)
      Set the JMRI program directory.
      void setProgramPath​(java.lang.String path)
      Set the JMRI program directory.
      void setScriptsPath​(Profile profile, java.lang.String path)
      Set the path to python scripts.
      void setUserFilesPath​(Profile profile, java.lang.String path)
      Set the user's files directory.
      java.net.URI urlToURI​(java.net.URL url)
      Return the URI for a given URL
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait