Class FileHelper
java.lang.Object
com.marginallyclever.convenience.helpers.FileHelper
Methods to make loading files from disk or jar resource easier.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
getAbsolutePathOrFilename
(String filename) Get the absolute path to a file.static String
static String
static String
static BufferedInputStream
Open a file.
-
Constructor Details
-
FileHelper
public FileHelper()
-
-
Method Details
-
open
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
-
getUserHome
-
getTempDirectory
-
getAbsolutePathOrFilename
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.
-