Package io.cui.tools.io
Class ClassPathLoader
- java.lang.Object
-
- io.cui.tools.io.ClassPathLoader
-
- All Implemented Interfaces:
FileLoader,Serializable
public class ClassPathLoader extends Object implements FileLoader
Variant ofFileLoaderthat loads files from the classpath.- Author:
- Oliver Wolff
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ClassPathLoader(String pathName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancanEqual(Object other)booleanequals(Object o)StructuredFilenamegetFileName()URLgetURL()inthashCode()InputStreaminputStream()This method should be within atry-with-resourcesstatement as it is not closed by the implementation.booleanisFilesystemLoader()booleanisReadable()StringtoString()
-
-
-
Constructor Detail
-
ClassPathLoader
public ClassPathLoader(String pathName)
- 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 Detail
-
isReadable
public boolean isReadable()
- Specified by:
isReadablein interfaceFileLoader- Returns:
- boolean indicating whether the concrete file exists and is accessible
-
inputStream
public InputStream 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
public boolean isFilesystemLoader()
- Specified by:
isFilesystemLoaderin interfaceFileLoader- Returns:
- boolean indicating that the loader loads from the file-system and not from the classpath
-
getURL
public URL getURL()
- Specified by:
getURLin interfaceFileLoader- Returns:
- an
URLon the corresponding file.
-
getFileName
public StructuredFilename getFileName()
- Specified by:
getFileNamein interfaceFileLoader- Returns:
- the filename in an appropriate presentation.
-
-