java.lang.Object
de.cuioss.tools.io.UrlLoader
- All Implemented Interfaces:
FileLoader,Serializable
This
FileLoader takes a URL as its parameter which is useful
when e.g. iterating over an enumeration of URLs from
ClassLoader.getResources(String). It converts the given URL to a
String and prefixes it with FileTypePrefix.URL.- Author:
- Sven Haag
- 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.booleanboolean
-
Constructor Details
-
UrlLoader
- Parameters:
url- representing a valid URL- Throws:
IllegalArgumentException- indicating that the given String represents a valid URL
-
UrlLoader
- Parameters:
url- hopefully a JAR URL
-
-
Method Details
-
isReadable
- Specified by:
isReadablein interfaceFileLoader- Returns:
- true, if a connection to
getURL()can be established
-
getFileName
- Specified by:
getFileNamein interfaceFileLoader- Returns:
- the filename in an appropriate presentation.
-
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. - Throws:
IOException
-
getURL
- Specified by:
getURLin interfaceFileLoader- Returns:
- an
URLon the corresponding file.
-
isFilesystemLoader
- Specified by:
isFilesystemLoaderin interfaceFileLoader- Returns:
- boolean indicating that the loader loads from the file-system and not from the classpath
-