java.lang.Object
de.cuioss.tools.io.FileSystemLoader
- All Implemented Interfaces:
FileLoader,FileReaderWriter,FileWriter,Serializable
File-system based variant. Responsible for all non
FileTypePrefix.CLASSPATH files.- Author:
- Oliver Wolff
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionFileSystemLoader(String pathName) FileSystemLoader(Path path) Variant that uses a path as the constructor argument -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcheckPathName(String pathName) Checks and modifies a given pathNamegetPath()getURL()This method should be within atry-with-resourcesstatement as it is not closed by the implementation.booleanTruncate and overwrite an existing file, or create the file if it doesn't initially exist.Methods 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, isReadableMethods inherited from interface de.cuioss.tools.io.FileWriter
getFileName, isWritable
-
Constructor Details
-
FileSystemLoader
- Parameters:
pathName- must not be null nor empty, must not start with the prefix "classpath:" but may start with the prefix "file:" and contain at least one character despite the prefix. On all other cases aIllegalArgumentExceptionwill be thrown.
-
FileSystemLoader
Variant that uses a path as the constructor argument- Parameters:
path- must not be null
-
-
Method Details
-
getPath
- Returns:
- the path
-
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
-
checkPathName
Checks and modifies a given pathName- Parameters:
pathName- must not be null nor empty, must not start with the prefix "classpath:" but may start with the prefix "file:" and contain at least one character despite the prefix. On all other cases aIllegalArgumentExceptionwill be thrown.- Returns:
- the normalized pathname without prefix
-
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.
-
outputStream
Truncate and overwrite an existing file, or create the file if it doesn't initially exist.- Specified by:
outputStreamin interfaceFileWriter- Returns:
- an
OutputStreamon the corresponding file. It implicitly checksFileWriter.isWritable()before accessing the file and will throw anIllegalStateExceptionin case it is not readable. - Throws:
IOException
-