java.lang.Object
de.cuioss.tools.io.ClassPathLoader
- All Implemented Interfaces:
FileLoader,Serializable
Variant of
FileLoader that loads files from the classpath.- Author:
- Oliver Wolff
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetURL()This method should be within atry-with-resourcesstatement as it is not closed by the implementation.booleanbooleanMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.cuioss.tools.io.FileLoader
getFileName
-
Constructor Details
-
ClassPathLoader
- Parameters:
pathName- must not be null nor empty, may start with the prefixFileTypePrefix.CLASSPATHbut not withFileTypePrefix.FILEand contain at least one character despite the prefix. On all other cases aIllegalArgumentExceptionwill be thrown.
-
-
Method Details
-
isReadable
- Specified by:
isReadablein interfaceFileLoader- Returns:
- boolean indicating whether the concrete file exists and is accessible
-
inputStream
Description copied from interface:FileLoaderThis method should be within atry-with-resourcesstatement as it is not closed by the implementation.- Specified by:
inputStreamin interfaceFileLoader- Returns:
- an
InputStreamon the corresponding file. It implicitly checksFileLoader.isReadable()before accessing the file and will throw anIllegalStateExceptionin case it is not readable.
-
isFilesystemLoader
- Specified by:
isFilesystemLoaderin interfaceFileLoader- Returns:
- boolean indicating that the loader loads from the file-system and not from the classpath
-
getURL
- Specified by:
getURLin interfaceFileLoader- Returns:
- an
URLon the corresponding file.
-