java.lang.Object
com.marginallyclever.convenience.helpers.FileHelper

public class FileHelper extends Object
Methods to make loading files from disk or jar resource easier.
  • Constructor Details

    • FileHelper

      public FileHelper()
  • Method Details

    • open

      public static BufferedInputStream open(String filename) throws IOException
      Open a file. open() looks in three places:
      - The file may be contained inside a zip, as indicated by the filename "zipname:filename".
      - The file may be a resource inside a jar file. - The file may be on disk.
      Parameters:
      filename - The file to open
      Returns:
      BufferedInputStream to the file contents
      Throws:
      IOException - file open failure
    • getUserDirectory

      public static String getUserDirectory()
    • getUserHome

      public static String getUserHome()
    • getTempDirectory

      public static String getTempDirectory()
    • getAbsolutePathOrFilename

      public static String getAbsolutePathOrFilename(String filename)
      Get the absolute path to a file. If the file is not found, return the filename. The file may be relative to the current working directory (user.dir), absolute, or a resource.
      Parameters:
      filename - the file to find
      Returns:
      the absolute path to the file, or the original filename if the file is not found.