Package org.apache.juneau.cp
Class LocalFile
java.lang.Object
org.apache.juneau.cp.LocalFile
Identifies a file located either on the classpath or file system.
Used to encapsulate basic resolution and retrieval of files regardless of where they are located.
See Also:
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
LocalFile
Constructor for classpath file.- Parameters:
clazz
- The class used to retrieve resources. Must not benull .clazzPath
- The path relative to the class. Must be a non-null normalized relative path.
-
LocalFile
Constructor for file system file.- Parameters:
path
- Filesystem file location. Must not benull .
-
-
Method Details
-
read
Returns the contents of this file.- Returns:
- An input stream of the contents of this file.
- Throws:
IOException
- If file could not be read.
-
size
Returns the size of this file.- Returns:
- The size of this file in bytes, or
-1 if not known. - Throws:
IOException
- If file size could not be determined.
-
cache
Caches the contents of this file into an internal byte array for quick future retrieval.- Returns:
- This object.
- Throws:
IOException
- If file could not be read.
-
getName
Returns the name of this file.- Returns:
- The name of this file.
-