Package io.cui.tools.io
Class UrlLoader
- java.lang.Object
-
- io.cui.tools.io.UrlLoader
-
- All Implemented Interfaces:
FileLoader,Serializable
public class UrlLoader extends Object implements FileLoader
ThisFileLoadertakes aURLas its parameter which is useful when e.g. iterating over an enumeration of URLs fromClassLoader.getResources(String). It converts the given URL to aStringand prefixes it withFileTypePrefix.URL.- Author:
- Sven Haag
- See Also:
- Serialized Form
-
-
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
-
UrlLoader
public UrlLoader(String url)
- Parameters:
url- representing a valid URL- Throws:
IllegalArgumentException- indicating that the given String represents a valid URL
-
-
Method Detail
-
isReadable
public boolean isReadable()
- Specified by:
isReadablein interfaceFileLoader- Returns:
- true, if a connection to
getURL()can be established
-
getFileName
public StructuredFilename getFileName()
- Specified by:
getFileNamein interfaceFileLoader- Returns:
- the filename in an appropriate presentation.
-
inputStream
public InputStream inputStream() throws IOException
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
public URL getURL()
- Specified by:
getURLin interfaceFileLoader- Returns:
- an
URLon the corresponding file.
-
isFilesystemLoader
public boolean isFilesystemLoader()
- Specified by:
isFilesystemLoaderin interfaceFileLoader- Returns:
- boolean indicating that the loader loads from the file-system and not from the classpath
-
-